]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: stream_interface: don't call chk_snd() on polled events
authorWilly Tarreau <w@1wt.eu>
Thu, 18 Jul 2013 20:09:48 +0000 (22:09 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 22 Jul 2013 07:31:55 +0000 (09:31 +0200)
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

index 90e4044fb0017dd188e98c7077d1c004678b42db..905612cef5dea28df849f976f4755f1de7fcaad4 100644 (file)
@@ -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.