]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: connection: only wake send/recv callbacks if the FD is active
authorWilly Tarreau <w@1wt.eu>
Thu, 28 Nov 2019 16:34:58 +0000 (17:34 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 27 Dec 2019 13:04:33 +0000 (14:04 +0100)
Since commit c3df4507fa ("MEDIUM: connections: Wake the upper layer even
if sending/receiving is disabled.") the send/recv callbacks are called
on I/O if the FD is ready and not just if it's active. This means that
in some situations (e.g. send ready but nothing to send) we may
needlessly enter the if() block, notice we're not subscribed, set
io_available=1 and call the wake() callback even if we're just called
for read activity. Better make sure we only do this when the FD is
active in that direction..

This may be backported as far as 2.0 though it should remain under
observation for a few weeks first as the risk of harm by a mistake
is higher than the trouble it should cause.

src/connection.c

index 7a2ab249948c29cc5eaf2ffa55021868b6abf4ff..320a387d7f06e0cd6684004b6fec72b3e5e66147 100644 (file)
@@ -71,7 +71,7 @@ void conn_fd_handler(int fd)
            conn->xprt_done_cb && conn->xprt_done_cb(conn) < 0)
                return;
 
-       if (conn->xprt && fd_send_ready(fd)) {
+       if (conn->xprt && fd_send_ready(fd) && fd_send_active(fd)) {
                /* force reporting of activity by clearing the previous flags :
                 * we'll have at least ERROR or CONNECTED at the end of an I/O,
                 * both of which will be detected below.
@@ -99,7 +99,7 @@ void conn_fd_handler(int fd)
         * that we must absolutely test conn->xprt at each step in case it suddenly
         * changes due to a quick unexpected close().
         */
-       if (conn->xprt && fd_recv_ready(fd)) {
+       if (conn->xprt && fd_recv_ready(fd) && fd_recv_active(fd)) {
                /* force reporting of activity by clearing the previous flags :
                 * we'll have at least ERROR or CONNECTED at the end of an I/O,
                 * both of which will be detected below.