From: Willy Tarreau Date: Thu, 28 Nov 2019 16:34:58 +0000 (+0100) Subject: BUG/MINOR: connection: only wake send/recv callbacks if the FD is active X-Git-Tag: v2.2-dev1~152 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=70ccb2cddfda60cf356cf2266245e055caa97132;p=thirdparty%2Fhaproxy.git BUG/MINOR: connection: only wake send/recv callbacks if the FD is active 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. --- diff --git a/src/connection.c b/src/connection.c index 7a2ab24994..320a387d7f 100644 --- a/src/connection.c +++ b/src/connection.c @@ -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.