mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-28 14:21:00 +01:00
BUG/MEDIUM: mux-h1: always apply the timeout on half-closed connections
The condition in h1_refresh_timeout() seems insufficient to properly take care of the half-closed timeout, because depending on the ordering of operations when performing the last send() to a client, the stream may or may not still be there and we may fail to shrink the client timeout on our last opportunity to do so. Here we want to make sure that the timeout is always reduced when the last chunk was sent and the shutdown completed, regardless of the presence of a stream or not. This is what this patch does. This should be backported as far as 2.0, and should fix the issue reported in #541.
This commit is contained in:
parent
ec00251c88
commit
4313d5ae98
12
src/mux_h1.c
12
src/mux_h1.c
@ -461,11 +461,19 @@ static void h1_refresh_timeout(struct h1c *h1c)
|
||||
{
|
||||
if (h1c->task) {
|
||||
h1c->task->expire = TICK_ETERNITY;
|
||||
if ((!h1c->h1s && !conn_is_back(h1c->conn)) || b_data(&h1c->obuf)) {
|
||||
if (h1c->flags & H1C_F_CS_SHUTDOWN) {
|
||||
/* half-closed connections switch to clientfin/serverfin
|
||||
* timeouts so that we don't hang too long on clients
|
||||
* that have gone away (especially in tunnel mode).
|
||||
*/
|
||||
h1c->task->expire = tick_add(now_ms, h1c->shut_timeout);
|
||||
task_queue(h1c->task);
|
||||
TRACE_DEVEL("refreshing connection's timeout (half-closed)", H1_EV_H1C_SEND, h1c->conn);
|
||||
} else if ((!h1c->h1s && !conn_is_back(h1c->conn)) || b_data(&h1c->obuf)) {
|
||||
/* front connections waiting for a stream, as well as any connection with
|
||||
* pending data, need a timeout.
|
||||
*/
|
||||
h1c->task->expire = tick_add(now_ms, ((h1c->flags & (H1C_F_CS_SHUTW_NOW|H1C_F_CS_SHUTDOWN))
|
||||
h1c->task->expire = tick_add(now_ms, ((h1c->flags & H1C_F_CS_SHUTW_NOW)
|
||||
? h1c->shut_timeout
|
||||
: h1c->timeout));
|
||||
task_queue(h1c->task);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user