]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: channel: Fix condition to know if a channel may send
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 3 Jun 2026 09:27:30 +0000 (11:27 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 3 Jun 2026 10:05:56 +0000 (12:05 +0200)
Historically, we considered a channel cannot send before the connection was
established. This was useful to know if the reserve should still be
respected for the receives. This was because it was possible to rewrite the
request on connection retry (because of http-send-name-header option).

However noadays, it is a useless limitation. Once data forwarding is
started, there is no longer rewrites on the request at the stream layer
(http-send-name-header option is handled by the muxes). And, since it is
possible to use small buffers to queue requests, it could be an issue,
because the reserve and the small buffer size are the same by default. Once
a small request was finally dequeued, the receives on client side were not
re-armed because we should still respect the reserve on receives
(channel_recv_limit() was returning 0 in that case).

To fix the issue, we must consider a channel may send since the underlying
stconn has reached the SC_ST_REQ state, instead of SC_ST_EST. Doing so, we
are able to ignore the reserve earlier and the receives can be re-armed even
with small buffers.

There is no reason to backport this patch, except if an issue is reported,
because only the 3.4 is concerned. But it could theorically be backported to
all stable versions.

include/haproxy/channel.h

index b76783e5af46316e8ad42c22718fbf2631020448..ebe316d8de5f1e4960a09fbae52a37c80031055b 100644 (file)
@@ -422,7 +422,7 @@ static inline int channel_is_rewritable(const struct channel *chn)
  */
 static inline int channel_may_send(const struct channel *chn)
 {
-       return chn_cons(chn)->state == SC_ST_EST;
+       return chn_cons(chn)->state >= SC_ST_REQ;
 }
 
 /* HTX version of channel_may_recv(). Returns non-zero if the channel can still