MINOR: ssl_sock: avoid iterating realloc(+1) on stored context
authorWilly Tarreau <w@1wt.eu>
Mon, 21 Aug 2023 06:12:12 +0000 (08:12 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 30 Aug 2023 09:43:06 +0000 (11:43 +0200)
commit2c6fe2400172e257c9758653d041c0a56f79f3d5
tree77d93a9faba2ccdb28b836098f28cc6bbd5d6adf
parent2cc53ecc8f4dc89da728ca9766e65579b7b50419
MINOR: ssl_sock: avoid iterating realloc(+1) on stored context

The SSL context storage in servers is per-thread, and the contents are
allocated for a length that is determined from the session. It turns out
that placing some traces there revealed that the realloc() that is called
to grow the area can be called multiple times in a row even for just
health checks, to grow the area by just one or two bytes. Given that
malloc() allocates in multiples of 8 or 16 anyway, let's round the
allocated size up to the nearest multiple of 8 to avoid this unneeded
operation.
src/ssl_sock.c