]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MAJOR: always clear the CO_FL_WAIT_* flags after updating polling flags
authorWilly Tarreau <w@1wt.eu>
Mon, 5 Nov 2012 19:00:43 +0000 (20:00 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 9 Nov 2012 21:09:33 +0000 (22:09 +0100)
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

index 3cdc58fca9ed0f8e634e3a404c38d22ae1c38664..8038a74648b14500a87cf329d626d4e2d41c78a9 100644 (file)
@@ -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 <c>'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