stdmem: free: only call _gcry_secmem_free if needed
authorJussi Kivilinna <jussi.kivilinna@iki.fi>
Mon, 5 Nov 2018 18:42:58 +0000 (20:42 +0200)
committerJussi Kivilinna <jussi.kivilinna@iki.fi>
Mon, 5 Nov 2018 18:42:58 +0000 (20:42 +0200)
commit23f56d3359ca7d152aa87874ddd6305171a91408
treeb9e98eb07867c004eb5c928b8186b34a7bc346e8
parentd6c6680ca31c05bafbb8becda56da051346eceb3
stdmem: free: only call _gcry_secmem_free if needed

* src/stdmem.c (_gcry_private_free): Check if memory is secure before
calling _gcry_secmem_free to avoid unnecessarily taking secmem lock.
--

Unnecessarily taking secmem lock on non-secure memory can result poor
performance on multi-threaded workloads:
  https://lists.gnupg.org/pipermail/gcrypt-devel/2018-August/004535.html

Reported-by: Christian Grothoff <grothoff@gnunet.org>
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
src/stdmem.c