]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: stconn: Don't needlessly wake the stream on send during fast-forward
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 9 Feb 2023 13:14:38 +0000 (14:14 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 10 Feb 2023 08:09:57 +0000 (09:09 +0100)
With a connection, when data are received, if these data are sent to the
opposite side because the fast-forwarding is possible, the stream may be
woken up on some conditions (at the end of sc_app_chk_snd_conn()):

  * The channel is shut for write
  * The SC is not in the "established" state
  * The stream must explicitly be woken up on write and all data was sent
  * The connection was just established.

A bug on the last condition was introduced with the commit d89884153
("MEDIUM: channel: Use CF_WRITE_EVENT instead of CF_WRITE_PARTIAL"). The
stream is now woken up on any write events.

This patch fixes this issue and restores the original behavior. No backport
is needed.

src/stconn.c

index 48c5a50ab3b4298b4f01f6c476a7379d4229b14d..9dfd77ca32e406876102cf7b49ad2d1d283f431b 100644 (file)
@@ -870,10 +870,11 @@ static void sc_app_chk_snd_conn(struct stconn *sc)
        /* in case of special condition (error, shutdown, end of write...), we
         * have to notify the task.
         */
-       if (likely((oc->flags & (CF_WRITE_EVENT|CF_SHUTW)) ||
-                 ((oc->flags & CF_WAKE_WRITE) &&
-                  ((channel_is_empty(oc) && !oc->to_forward) ||
-                   !sc_state_in(sc->state, SC_SB_EST))))) {
+       if (likely((oc->flags & CF_SHUTW) ||
+                  ((oc->flags & CF_WRITE_EVENT) && sc->state < SC_ST_EST) ||
+                  ((oc->flags & CF_WAKE_WRITE) &&
+                   ((channel_is_empty(oc) && !oc->to_forward) ||
+                    !sc_state_in(sc->state, SC_SB_EST))))) {
        out_wakeup:
                if (!(sc->flags & SC_FL_DONT_WAKE))
                        task_wakeup(sc_strm_task(sc), TASK_WOKEN_IO);