]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: stream: don't try to send first in process_stream()
authorWilly Tarreau <w@1wt.eu>
Thu, 25 Oct 2018 08:42:39 +0000 (10:42 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 28 Oct 2018 12:47:00 +0000 (13:47 +0100)
The rationale here is that we should never need to try to send() at the
beginning of process_stream() because :
  - if something was pending, it's very unlikely that it was unblocked
    and not sent just between the last poll() and the wakeup instant.
  - if something pending was recently sent, then we don't have anything
    to send anymore.

So at first glance it doesn't seem like there could be any valid case
where trying to send before entering the function brings any benefit.

src/stream.c

index 6f5372809eac72783120c120c347546256cbc912..4e2db45afc1d46cdd8ff6976d164aad30c4546f4 100644 (file)
@@ -1669,25 +1669,16 @@ struct task *process_stream(struct task *t, void *context, unsigned short state)
        si_f = &s->si[0];
        si_b = &s->si[1];
 
-       /* First, attempd to do I/Os */
+       /* First, attempt to receive pending data from I/O layers */
        cs = objt_cs(si_f->end);
-       if (cs) {
-               if (!(si_f->wait_event.wait_reason & SUB_CAN_SEND) &&
-                   co_data(si_oc(si_f)))
-                       si_cs_send(cs);
-               if (!(si_f->wait_event.wait_reason & SUB_CAN_RECV) &&
-                   (!(si_f->flags & SI_FL_WAIT_ROOM) || !c_size(req)))
-                       si_cs_recv(cs);
-       }
+       if (cs && !(si_f->wait_event.wait_reason & SUB_CAN_RECV) &&
+           (!(si_f->flags & SI_FL_WAIT_ROOM) || !c_size(req)))
+               si_cs_recv(cs);
+
        cs = objt_cs(si_b->end);
-       if (cs) {
-               if (!(si_b->wait_event.wait_reason & SUB_CAN_SEND) &&
-                   co_data(si_oc(si_b)))
-                       si_cs_send(cs);
-               if (!(si_b->wait_event.wait_reason & SUB_CAN_RECV) &&
-                   (!(si_b->flags & SI_FL_WAIT_ROOM) || !c_size(res)))
+       if (cs && !(si_b->wait_event.wait_reason & SUB_CAN_RECV) &&
+           (!(si_b->flags & SI_FL_WAIT_ROOM) || !c_size(res)))
                si_cs_recv(cs);
-       }
 redo:
 
        //DPRINTF(stderr, "%s:%d: cs=%d ss=%d(%d) rqf=0x%08x rpf=0x%08x\n", __FUNCTION__, __LINE__,