From: Willy Tarreau Date: Thu, 18 Jul 2013 20:09:48 +0000 (+0200) Subject: BUG/MINOR: stream_interface: don't call chk_snd() on polled events X-Git-Tag: v1.5-dev20~331 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5007d2aa33c25f521f94733af56422062f80ba4b;p=thirdparty%2Fhaproxy.git BUG/MINOR: stream_interface: don't call chk_snd() on polled events As explained in previous patch, we incorrectly call chk_snd() when performing a read even if the write event is already subscribed to poll(). This is counter-productive because we're almost sure to get an EAGAIN. A quick test shows that this fix halves the number of failed splice() calls without adding any extra work on other syscalls. This could have been tagged as an improvement, but since this behaviour made the analysis of previous bug more complex, it still qualifies as a fix. --- diff --git a/src/stream_interface.c b/src/stream_interface.c index 90e4044fb0..905612cef5 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -807,6 +807,14 @@ static void stream_int_chk_snd_conn(struct stream_interface *si) !(si->flags & SI_FL_WAIT_DATA)) /* not waiting for data */ return; + if (si->conn->flags & (CO_FL_DATA_WR_ENA|CO_FL_CURR_WR_ENA)) { + /* already subscribed to write notifications, will be called + * anyway, so let's avoid calling it especially if the reader + * is not ready. + */ + return; + } + if (!(si->conn->flags & (CO_FL_HANDSHAKE|CO_FL_WAIT_L4_CONN|CO_FL_WAIT_L6_CONN))) { /* Before calling the data-level operations, we have to prepare * the polling flags to ensure we properly detect changes.