MINOR: conn_stream: add cs_send() as a default snd_buf() function
This function is generic and is able to automatically transfer data from a
buffer to the conn_stream's tx buffer. It does this automatically if the mux
doesn't define another snd_buf() function.
It cannot yet be used as-is with the conn_stream's txbuf without risking to
lose data on close since conn_streams need to be orphaned for this.
diff --git a/include/proto/connection.h b/include/proto/connection.h
index 2111f67..580ae9a 100644
--- a/include/proto/connection.h
+++ b/include/proto/connection.h
@@ -46,6 +46,7 @@
/* conn_stream functions */
size_t __cs_recv(struct conn_stream *cs, struct buffer *buf, size_t count, int flags);
+size_t __cs_send(struct conn_stream *cs, struct buffer *buf, size_t count, int flags);
/* receive a PROXY protocol header over a connection */
int conn_recv_proxy(struct connection *conn, int flag);
@@ -314,6 +315,17 @@
return __cs_recv(cs, buf, count, flags);
}
+/* conn_stream send function. Uses mux->snd_buf() if defined, otherwise
+ * falls back to __cs_send().
+ */
+static inline size_t cs_send(struct conn_stream *cs, struct buffer *buf, size_t count, int flags)
+{
+ if (cs->conn->mux->snd_buf)
+ return cs->conn->mux->snd_buf(cs, buf, count, flags);
+ else
+ return __cs_send(cs, buf, count, flags);
+}
+
/***** Event manipulation primitives for use by DATA I/O callbacks *****/
/* The __conn_* versions do not propagate to lower layers and are only meant
* to be used by handlers called by the connection handler. The other ones