/* 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);
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
goto out;
if (b_data(&check->bo)) {
- conn->mux->snd_buf(cs, &check->bo, b_data(&check->bo), 0);
+ cs_send(cs, &check->bo, b_data(&check->bo), 0);
b_realign_if_empty(&check->bo);
if (conn->flags & CO_FL_ERROR || cs->flags & CS_FL_ERROR) {
chk_report_conn_err(check, errno, 0);
int ret;
__cs_want_send(cs);
- ret = conn->mux->snd_buf(cs, &check->bo, b_data(&check->bo), 0);
+ ret = cs_send(cs, &check->bo, b_data(&check->bo), 0);
b_realign_if_empty(&check->bo);
if (ret <= 0) {
return ret;
}
+/*
+ * default cs send() : this one is used when mux->snd_buf == NULL. It puts up to
+ * <count> bytes from <buf> into cs->txbuf. The number of bytes transferred is
+ * returned. Here we don't care if cs->txbuf is allocated or not. If not, it
+ * will be swapped with <buf>.
+ */
+size_t __cs_send(struct conn_stream *cs, struct buffer *buf, size_t count, int flags)
+{
+ return b_xfer(&cs->txbuf, buf, count);
+}
+
/*
* Get data length from tlv
*/
if (oc->flags & CF_STREAMER)
send_flag |= CO_SFL_STREAMER;
- ret = conn->mux->snd_buf(cs, &oc->buf, co_data(oc), send_flag);
+ ret = cs_send(cs, &oc->buf, co_data(oc), send_flag);
if (ret > 0) {
did_send = 1;
oc->flags |= CF_WRITE_PARTIAL | CF_WROTE_DATA | CF_WRITE_EVENT;