You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.9 KiB

  1. commit 30ba96df349ace825749a57490defeb50001a550
  2. Author: Emeric Brun <ebrun@haproxy.com>
  3. Date: Wed Oct 10 14:51:02 2018 +0200
  4. BUG/MEDIUM: Cur/CumSslConns counters not threadsafe.
  5. CurSslConns inc/dec operations are not threadsafe. The unsigned CurSslConns
  6. counter can wrap to a negative value. So we could notice connection rejects
  7. because of MaxSslConns limit artificially exceeded.
  8. CumSslConns inc operation are also not threadsafe so we could miss
  9. some connections and show inconsistenties values compared to CumConns.
  10. This fix should be backported to v1.8.
  11. (cherry picked from commit 7ad43e7928c9a61b40332e4d5e9a7ccc33e6b65b)
  12. Signed-off-by: Willy Tarreau <w@1wt.eu>
  13. diff --git a/src/ssl_sock.c b/src/ssl_sock.c
  14. index 2da0df68..6eed8022 100644
  15. --- a/src/ssl_sock.c
  16. +++ b/src/ssl_sock.c
  17. @@ -491,7 +491,7 @@ static void ssl_async_fd_free(int fd)
  18. /* Now we can safely call SSL_free, no more pending job in engines */
  19. SSL_free(ssl);
  20. - sslconns--;
  21. + HA_ATOMIC_SUB(&sslconns, 1);
  22. HA_ATOMIC_SUB(&jobs, 1);
  23. }
  24. /*
  25. @@ -5011,8 +5011,8 @@ static int ssl_sock_init(struct connection *conn)
  26. /* leave init state and start handshake */
  27. conn->flags |= CO_FL_SSL_WAIT_HS | CO_FL_WAIT_L6_CONN;
  28. - sslconns++;
  29. - totalsslconns++;
  30. + HA_ATOMIC_ADD(&sslconns, 1);
  31. + HA_ATOMIC_ADD(&totalsslconns, 1);
  32. return 0;
  33. }
  34. else if (objt_listener(conn->target)) {
  35. @@ -5062,8 +5062,8 @@ static int ssl_sock_init(struct connection *conn)
  36. conn->flags |= CO_FL_EARLY_SSL_HS;
  37. #endif
  38. - sslconns++;
  39. - totalsslconns++;
  40. + HA_ATOMIC_ADD(&sslconns, 1);
  41. + HA_ATOMIC_ADD(&totalsslconns, 1);
  42. return 0;
  43. }
  44. /* don't know how to handle such a target */
  45. @@ -5713,7 +5713,7 @@ static void ssl_sock_close(struct connection *conn) {
  46. #endif
  47. SSL_free(conn->xprt_ctx);
  48. conn->xprt_ctx = NULL;
  49. - sslconns--;
  50. + HA_ATOMIC_SUB(&sslconns, 1);
  51. }
  52. }