]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: tevt: Don't duplicate termination event during reporting
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 20 Jan 2025 14:35:47 +0000 (15:35 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 31 Jan 2025 09:41:50 +0000 (10:41 +0100)
It is hard to never detect the same event several time without painful
tests. In other words, the same termination event can be reported several
time and this must be handled. To do so, "tevt_report_event" macro is
updated to ignore an event if the last reported one is of the same type, for
the same location. Of course, if the same event is reported several times at
different moment, it will not be detected.

include/haproxy/connection.h

index c0ed51e5db8176f98ab2eb9642c912b471d7d0c9..33607ea3a265bd10e360957dd8f99c0f8d46a78a 100644 (file)
@@ -746,14 +746,17 @@ static inline int conn_pr_mode_to_proto_mode(int proxy_mode)
 /* Must be used to report add an event in <_evt> termination events log.
  * For now, it only handles 32-bits integers.
  */
-#define tevt_report_event(_evts, loc, type) ({ \
-                                               \
-       if (!((_evts) & 0xff000000)) {          \
-               (_evts) <<= 8;                  \
-               (_evts) |= (loc) << 4;          \
-               (_evts) |= (type);              \
-       }                                       \
-       (_evts);                                \
+#define tevt_report_event(_evts, loc, type) ({                 \
+                                                               \
+       unsigned int _evt = ((loc) << 4) | (type);              \
+                                                               \
+       if (!((_evts) & 0xff000000) &&                          \
+           (unsigned char)_evt != (unsigned char)(_evts)) {    \
+               (_evts) <<= 8;                                  \
+               (_evts) |= (loc) << 4;                          \
+               (_evts) |= (type);                              \
+       }                                                       \
+       (_evts);                                                \
 })
 
 /* Function to convert a termination events log to a string */