]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: ssl: make SSL counters atomic
authorWilly Tarreau <w@1wt.eu>
Mon, 22 Nov 2021 16:46:13 +0000 (17:46 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 22 Nov 2021 16:46:13 +0000 (17:46 +0100)
SSL counters were added with commit d0447a7c3 ("MINOR: ssl: add counters
for ssl sessions") in 2.4, but their updates were not atomic, so it's
likely that under significant loads they are not correct.

This needs to be backported to 2.4.

src/ssl_sock.c

index 2df48e0343cafe6928a536906f25c9b21b2e4bea..e3e3abf62729837e078119a69d8080d5d98423ef 100644 (file)
@@ -5844,13 +5844,13 @@ reneg_ok:
                }
 
                if (counters) {
-                       ++counters->sess;
-                       ++counters_px->sess;
+                       HA_ATOMIC_INC(&counters->sess);
+                       HA_ATOMIC_INC(&counters_px->sess);
                }
        }
        else if (counters) {
-               ++counters->reused_sess;
-               ++counters_px->reused_sess;
+               HA_ATOMIC_INC(&counters->reused_sess);
+               HA_ATOMIC_INC(&counters_px->reused_sess);
        }
 
        /* The connection is now established at both layers, it's time to leave */
@@ -5876,8 +5876,8 @@ reneg_ok:
        }
 
        if (counters) {
-               ++counters->failed_handshake;
-               ++counters_px->failed_handshake;
+               HA_ATOMIC_INC(&counters->failed_handshake);
+               HA_ATOMIC_INC(&counters_px->failed_handshake);
        }
 
        /* Fail on all other handshake errors */