From c9f7804aad77567c3a533dd654c1ffe6f910bb55 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 5 Nov 2012 20:00:43 +0100 Subject: [PATCH] BUG/MAJOR: always clear the CO_FL_WAIT_* flags after updating polling flags The CO_FL_WAIT_* flags were not cleared after updating polling flags. This means that any caller of these functions that did not clear it would enable polling instead of speculative I/O. This happens during the stream interface update call which is performed from the session handler for example. As of now it's not a problem yet because speculative I/O and polling are handled the same way. However with upcoming changes it does cause some deadlocks because enabling read processing on a file descriptor where everything was already read will do nothing until something new happens on this FD. The correct fix consists in clearing the flags while leaving the update functions. This fix does not need any backport as it was introduced with recent connection changes (dev12) and not triggered until last commit. --- src/connection.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/connection.c b/src/connection.c index 3cdc58fca9..8038a74648 100644 --- a/src/connection.c +++ b/src/connection.c @@ -201,7 +201,7 @@ void conn_update_data_polling(struct connection *c) fd_stop_send(c->t.sock.fd); f &= ~CO_FL_CURR_WR_ENA; } - c->flags = f; + c->flags = f & ~(CO_FL_WAIT_RD | CO_FL_WAIT_WR); } /* Update polling on connection 's file descriptor depending on its current @@ -249,7 +249,7 @@ void conn_update_sock_polling(struct connection *c) fd_stop_send(c->t.sock.fd); f &= ~CO_FL_CURR_WR_ENA; } - c->flags = f; + c->flags = f & ~(CO_FL_WAIT_RD | CO_FL_WAIT_WR); } /* This handshake handler waits a PROXY protocol header at the beginning of the -- 2.47.3