From 5007d2aa33c25f521f94733af56422062f80ba4b Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 18 Jul 2013 22:09:48 +0200 Subject: [PATCH] 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. --- src/stream_interface.c | 8 ++++++++ 1 file changed, 8 insertions(+) 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. -- 2.47.3