diff options
author | Martin Willi <martin@strongswan.org> | 2008-11-05 12:37:37 +0000 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2008-11-05 12:37:37 +0000 |
commit | 2abc66b977c41f1a1240fe21c921a6df58bd4157 (patch) | |
tree | e7f11f0c2ae9d95e92724314c8eae27dd94b194b /src/libstrongswan/plugins/openssl/openssl_plugin.c | |
parent | 465fe85ee11de82987213f8392ca5a71702bfcfd (diff) | |
download | strongswan-2abc66b977c41f1a1240fe21c921a6df58bd4157.tar.bz2 strongswan-2abc66b977c41f1a1240fe21c921a6df58bd4157.tar.xz |
proper cleanup of openssl locking code
Diffstat (limited to 'src/libstrongswan/plugins/openssl/openssl_plugin.c')
-rw-r--r-- | src/libstrongswan/plugins/openssl/openssl_plugin.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/libstrongswan/plugins/openssl/openssl_plugin.c b/src/libstrongswan/plugins/openssl/openssl_plugin.c index 744b6e89a..35df1b073 100644 --- a/src/libstrongswan/plugins/openssl/openssl_plugin.c +++ b/src/libstrongswan/plugins/openssl/openssl_plugin.c @@ -50,20 +50,23 @@ struct private_openssl_plugin_t { /** * Array of static mutexs, with CRYPTO_num_locks() mutex */ -static mutex_t **mutex; +static mutex_t **mutex = NULL; /** * Locking callback for static locks */ static void locking_function(int mode, int type, const char *file, int line) { - if (mode & CRYPTO_LOCK) + if (mutex) { - mutex[type]->lock(mutex[type]); - } - else - { - mutex[type]->unlock(mutex[type]); + if (mode & CRYPTO_LOCK) + { + mutex[type]->lock(mutex[type]); + } + else + { + mutex[type]->unlock(mutex[type]); + } } } @@ -155,6 +158,7 @@ static void threading_cleanup() mutex[i]->destroy(mutex[i]); } free(mutex); + mutex = NULL; } /** @@ -182,6 +186,8 @@ static void destroy(private_openssl_plugin_t *this) ENGINE_cleanup(); EVP_cleanup(); + threading_cleanup(); + free(this); } |