mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-05-04 12:41:00 +02:00
MEDIUM: mux: Remove const on the buffer in mux->snd_buf()
This is a partial revert of the commit deccd1116 ("MEDIUM: mux: make
mux->snd_buf() take the byte count in argument"). It is a requirement to do
zero-copy transfers. This will be mandatory when the TX buffer of the
conn_stream will be used.
So, now, data are consumed by mux->snd_buf() and not only sent. So it needs to
update the buffer state. On its side, the caller must be aware the buffer can be
replaced y an empty or unallocated one.
As a side effet of this change, the function co_set_data() is now only responsible
to update the channel set, by update ->output field.
This commit is contained in:
parent
a8694654ba
commit
d44a9b3627
@ -193,7 +193,6 @@ static inline void c_realign_if_empty(struct channel *chn)
|
||||
/* Sets the amount of output for the channel */
|
||||
static inline void co_set_data(struct channel *c, size_t output)
|
||||
{
|
||||
c->buf.data += output - c->output;
|
||||
c->output = output;
|
||||
}
|
||||
|
||||
|
||||
@ -311,7 +311,7 @@ struct mux_ops {
|
||||
int (*wake)(struct connection *conn); /* mux-layer callback to report activity, mandatory */
|
||||
void (*update_poll)(struct conn_stream *cs); /* commit cs flags to mux/conn */
|
||||
size_t (*rcv_buf)(struct conn_stream *cs, struct buffer *buf, size_t count, int flags); /* Called from the upper layer to get data */
|
||||
size_t (*snd_buf)(struct conn_stream *cs, const struct buffer *buf, size_t count, int flags); /* Called from the upper layer to send data */
|
||||
size_t (*snd_buf)(struct conn_stream *cs, struct buffer *buf, size_t count, int flags); /* Called from the upper layer to send data */
|
||||
int (*rcv_pipe)(struct conn_stream *cs, struct pipe *pipe, unsigned int count); /* recv-to-pipe callback */
|
||||
int (*snd_pipe)(struct conn_stream *cs, struct pipe *pipe); /* send-to-pipe callback */
|
||||
void (*shutr)(struct conn_stream *cs, enum cs_shr_mode); /* shutr function */
|
||||
|
||||
@ -771,7 +771,7 @@ static void __event_srv_chk_w(struct conn_stream *cs)
|
||||
goto out;
|
||||
|
||||
if (b_data(&check->bo)) {
|
||||
b_del(&check->bo, conn->mux->snd_buf(cs, &check->bo, b_data(&check->bo), 0));
|
||||
conn->mux->snd_buf(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);
|
||||
@ -2700,7 +2700,6 @@ static int tcpcheck_main(struct check *check)
|
||||
|
||||
__cs_want_send(cs);
|
||||
ret = conn->mux->snd_buf(cs, &check->bo, b_data(&check->bo), 0);
|
||||
b_del(&check->bo, ret);
|
||||
b_realign_if_empty(&check->bo);
|
||||
|
||||
if (ret <= 0) {
|
||||
|
||||
@ -3415,7 +3415,7 @@ static int h2_subscribe(struct conn_stream *cs, int event_type, void *param)
|
||||
}
|
||||
|
||||
/* Called from the upper layer, to send data */
|
||||
static size_t h2_snd_buf(struct conn_stream *cs, const struct buffer *buf, size_t count, int flags)
|
||||
static size_t h2_snd_buf(struct conn_stream *cs, struct buffer *buf, size_t count, int flags)
|
||||
{
|
||||
struct h2s *h2s = cs->ctx;
|
||||
size_t total = 0;
|
||||
@ -3486,6 +3486,7 @@ static size_t h2_snd_buf(struct conn_stream *cs, const struct buffer *buf, size_
|
||||
LIST_ADDQ(&h2s->h2c->fctl_list, &h2s->list);
|
||||
}
|
||||
|
||||
b_del(buf, total);
|
||||
return total;
|
||||
}
|
||||
|
||||
|
||||
@ -159,9 +159,13 @@ static size_t mux_pt_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t
|
||||
}
|
||||
|
||||
/* Called from the upper layer, to send data */
|
||||
static size_t mux_pt_snd_buf(struct conn_stream *cs, const struct buffer *buf, size_t count, int flags)
|
||||
static size_t mux_pt_snd_buf(struct conn_stream *cs, struct buffer *buf, size_t count, int flags)
|
||||
{
|
||||
return cs->conn->xprt->snd_buf(cs->conn, buf, count, flags);
|
||||
size_t ret = cs->conn->xprt->snd_buf(cs->conn, buf, count, flags);
|
||||
|
||||
if (ret > 0)
|
||||
b_del(buf, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Called from the upper layer, to subscribe to events */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user