mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-03-03 18:09:25 +00:00
MINOR: mux-h1: Consume channel's data in a loop in h1_snd_buf()
In h1_snd_buf(), the data sending is done synchronously, as much as possible. So if some data remains in the channel's buffer, because there was not enougth place in the output buffer, it may be good the retry after a send because some space may have been released when sending. Most of time the output buffer is empty and all channel's data are consumed the first time. And if no data are sent, we don't retry to do more. So the loop is just here to optimize edge cases without any cost for all others.
This commit is contained in:
parent
f96c322664
commit
5d37dac785
37
src/mux_h1.c
37
src/mux_h1.c
@ -1784,36 +1784,39 @@ static size_t h1_snd_buf(struct conn_stream *cs, struct buffer *buf, size_t coun
|
||||
{
|
||||
struct h1s *h1s = cs->ctx;
|
||||
struct h1c *h1c;
|
||||
size_t ret = 0;
|
||||
size_t total = 0;
|
||||
|
||||
if (!h1s)
|
||||
return ret;
|
||||
return 0;
|
||||
|
||||
h1c = h1s->h1c;
|
||||
|
||||
if (h1c->flags & H1C_F_CS_WAIT_CONN)
|
||||
return 0;
|
||||
|
||||
if (!(h1c->flags & (H1C_F_OUT_FULL|H1C_F_OUT_ALLOC)))
|
||||
ret = h1_process_output(h1c, buf, count);
|
||||
if (ret > 0) {
|
||||
h1_send(h1c);
|
||||
while (total != count) {
|
||||
size_t ret = 0;
|
||||
|
||||
/* We need to do that because of the infinite forwarding. <buf>
|
||||
* contains HTX messages so when infinite forwarding is enabled,
|
||||
* count is equal to the buffer size. From outside, the buffer
|
||||
* appears as full.
|
||||
*/
|
||||
if (!b_data(buf))
|
||||
ret = count;
|
||||
if (!(h1c->flags & (H1C_F_OUT_FULL|H1C_F_OUT_ALLOC)))
|
||||
ret = h1_process_output(h1c, buf, count);
|
||||
if (!ret)
|
||||
break;
|
||||
total += ret;
|
||||
if (!h1_send(h1c))
|
||||
break;
|
||||
}
|
||||
|
||||
if (count && ret != count) {
|
||||
/* We need to do that because of the infinite forwarding. <buf>
|
||||
* contains HTX messages so when infinite forwarding is enabled,
|
||||
* count is equal to the buffer size. From outside, the buffer
|
||||
* appears as full.
|
||||
*/
|
||||
if (!b_data(buf))
|
||||
total = count;
|
||||
else if (total != count) {
|
||||
if (!(h1c->wait_event.wait_reason & SUB_CAN_SEND))
|
||||
cs->conn->xprt->subscribe(cs->conn, SUB_CAN_SEND, &h1c->wait_event);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return total;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_HAP_LINUX_SPLICE)
|
||||
|
Loading…
Reference in New Issue
Block a user