From: Willy Tarreau Date: Mon, 26 Feb 2018 19:08:13 +0000 (+0100) Subject: MEDIUM: stream-int: automatically call si_cs_recv_cb() if the cs has data on wake() X-Git-Tag: v1.9-dev1~50 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67b1e78f6818b121ffb8fc42c61fd2653b82fca7;p=thirdparty%2Fhaproxy.git MEDIUM: stream-int: automatically call si_cs_recv_cb() if the cs has data on wake() If the cs has data pending or shutdown and the input channel is still waiting for reads, let's simply call the recv() function from the wake() callback. This will allow the lower layers to simply wake the upper one up without having to consider the recv() nor anything else. --- diff --git a/src/stream_interface.c b/src/stream_interface.c index a0c73bca2f..655c882e65 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -581,6 +581,14 @@ static int si_cs_wake_cb(struct conn_stream *cs) struct channel *ic = si_ic(si); struct channel *oc = si_oc(si); + /* if the CS's input buffer already has data available, let's try to + * receive now. The new muxes do this. The CS_FL_REOS is another cause + * for recv() (received only an empty response). + */ + if (!(cs->flags & CS_FL_EOS) && + (cs->flags & (CS_FL_DATA_RD_ENA|CS_FL_REOS|CS_FL_RCV_MORE)) > CS_FL_DATA_RD_ENA) + si_cs_recv_cb(cs); + /* First step, report to the stream-int what was detected at the * connection layer : errors and connection establishment. */