From: Willy Tarreau Date: Thu, 25 Oct 2018 12:02:47 +0000 (+0200) Subject: MINOR: stream-int: don't needlessly call si_cs_send() in si_cs_process() X-Git-Tag: v1.9-dev5~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=908d26fd03fdc20d623454f683a02518f5558c7a;p=thirdparty%2Fhaproxy.git MINOR: stream-int: don't needlessly call si_cs_send() in si_cs_process() There's a call there to si_cs_send() while we're supposed to come from si_cs_io_cb() which has just done it. But in fact we can also come here as a lower layer callback from ->wake() after a connection is established. Since most of the time we'll end up here with either no data in the buffer or a blocked output, let's simply check if we're already susbcribed to send events before calling si_cs_send(). --- diff --git a/src/stream_interface.c b/src/stream_interface.c index 60098da395..dbc9d167a4 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -568,8 +568,9 @@ static int si_cs_process(struct conn_stream *cs) int wait_room = si->flags & SI_FL_WAIT_ROOM; /* If we have data to send, try it now */ - if (!channel_is_empty(oc) && objt_cs(si->end)) - si_cs_send(objt_cs(si->end)); + if (!channel_is_empty(oc) && !(si->wait_event.wait_reason & SUB_CAN_SEND)) + si_cs_send(cs); + /* First step, report to the stream-int what was detected at the * connection layer : errors and connection establishment. */