]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: ssl: use atomic ops to update global shctx stats
authorWilly Tarreau <w@1wt.eu>
Tue, 15 Jun 2021 14:39:22 +0000 (16:39 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 15 Jun 2021 14:52:07 +0000 (16:52 +0200)
The global shctx lookups and misses was updated without using atomic
ops, so the stats available in "show info" are very likely off by a few
units over time. This should be backported as far as 1.8. Versions
without _HA_ATOMIC_INC() can use HA_ATOMIC_ADD(,1).

src/ssl_sock.c

index fcb089b92d16eb16334c85d8a9c5679fd1b4a1bc..68391326d79d96e8b78c4f1cb2fc03109ee1f69a 100644 (file)
@@ -4061,7 +4061,7 @@ SSL_SESSION *sh_ssl_sess_get_cb(SSL *ssl, __OPENSSL_110_CONST__ unsigned char *k
        SSL_SESSION *sess;
        struct shared_block *first;
 
-       global.shctx_lookups++;
+       _HA_ATOMIC_INC(&global.shctx_lookups);
 
        /* allow the session to be freed automatically by openssl */
        *do_copy = 0;
@@ -4081,7 +4081,7 @@ SSL_SESSION *sh_ssl_sess_get_cb(SSL *ssl, __OPENSSL_110_CONST__ unsigned char *k
        if (!sh_ssl_sess) {
                /* no session found: unlock cache and exit */
                shctx_unlock(ssl_shctx);
-               global.shctx_misses++;
+               _HA_ATOMIC_INC(&global.shctx_misses);
                return NULL;
        }