From c640ef1a7de5d13504599f85ca3cf3c282128a05 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 3 Dec 2019 18:13:04 +0100 Subject: [PATCH] BUG/MINOR: stream-int: avoid calling rcv_buf() when splicing is still possible In si_cs_recv(), we can end up with a partial splice() call that will be followed by an attempt to us rcv_buf(). Sometimes this works and places data into the buffer, which then prevent splicing from being used, and this causes splice() and recvfrom() calls to alternate. Better simply refrain from calling rcv_buf() when there are data in the pipe and still data to be forwarded. Usually this indicates that we've ate everything available and that we still want to use splice() on subsequent calls. This should be backported to 2.1 and 2.0. --- src/stream_interface.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/stream_interface.c b/src/stream_interface.c index aa9cf20324..1d84ca9ad7 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -1327,6 +1327,13 @@ int si_cs_recv(struct conn_stream *cs) ic->pipe = NULL; } + if (ic->pipe && ic->to_forward && !(flags & CO_RFL_BUF_FLUSH)) { + /* don't break splicing by reading, but still call rcv_buf() + * to pass the flag. + */ + goto done_recv; + } + /* now we'll need a input buffer for the stream */ if (!si_alloc_ibuf(si, &(si_strm(si)->buffer_wait))) goto end_recv; -- 2.39.5