]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: stconn: make the SE_FL_ERR_PENDING to ERROR transition systematic
authorWilly Tarreau <w@1wt.eu>
Tue, 23 May 2023 14:08:22 +0000 (16:08 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 23 May 2023 14:17:04 +0000 (16:17 +0200)
During a code audit of the various situations that promote ERR_PENDING to
ERROR, it appeared that:
  - all muxes use se_fl_set_error() to set it, which chooses either based
    on EOI/EOS presence ;
  - EOI/EOS that arrive late after ERR_PENDING were not systematically
    upgraded to ERROR

This results in confusion about how such ERROR or ERR_PENDING ought to
be handled, which is not quite desirable.

This patch adds a test to se_fl_set() to detect if we're setting EOI or
EOS while ERR_PENDING is present, or the other way around so that any
sequence of EOI/EOS <-> ERR_PENDING results in ERROR being set. This
way there will no longer be possible situations where ERROR is missing
while the other ones are set.

include/haproxy/stconn.h

index 97460c7c5d3f05ccc4dd016cea6baf5b6ee998a0..8d9ac665060d418335e61c24ea1729fdcb7ceef8 100644 (file)
@@ -77,8 +77,14 @@ static forceinline void se_fl_setall(struct sedesc *se, uint all)
        se->flags = all;
 }
 
+/* sets flags <on> on se->flags and handles ERR_PENDING to ERROR promotion if
+ * needed (upon EOI/EOS).
+ */
 static forceinline void se_fl_set(struct sedesc *se, uint on)
 {
+       if (((on & (SE_FL_EOS|SE_FL_EOI)) && se->flags & SE_FL_ERR_PENDING) ||
+           ((on & SE_FL_ERR_PENDING) && se->flags & (SE_FL_EOI|SE_FL_EOS)))
+               on |= SE_FL_ERROR;
        se->flags |= on;
 }