From 0f8d3ab362e9d3050e4862688464642a05354ec8 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 25 Oct 2018 10:42:39 +0200 Subject: [PATCH] MEDIUM: stream: don't try to send first in process_stream() 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 | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/stream.c b/src/stream.c index 6f5372809..4e2db45af 100644 --- a/src/stream.c +++ b/src/stream.c @@ -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); - } - 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_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 && !(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__,