diff options
author | Nick Mathewson <nickm@torproject.org> | 2005-04-01 02:37:10 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2005-04-01 02:37:10 +0000 |
commit | 837d7dff69c9844e40d9cdd440906e2dbe97106c (patch) | |
tree | 52830e471ad1d4ef50ad25ab398fa5047edf3427 | |
parent | e04a82ecaf1641961b64580a8c1694a54606ede4 (diff) | |
download | tor-837d7dff69c9844e40d9cdd440906e2dbe97106c.tar.gz tor-837d7dff69c9844e40d9cdd440906e2dbe97106c.zip |
Try to make crash-on-shutdown bug harder to trigger.
svn:r3939
-rw-r--r-- | src/common/crypto.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c index c88be4b829..14ffe3cfa9 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -177,12 +177,15 @@ int crypto_global_cleanup() ERR_free_strings(); #ifdef TOR_IS_MULTITHREADED if (_n_openssl_mutexes) { + int n = _n_openssl_mutexes; + tor_mutex_t **ms = _openssl_mutexes; int i; - for (i=0;i<_n_openssl_mutexes;++i) { - tor_mutex_free(_openssl_mutexes[i]); - } - tor_free(_openssl_mutexes); + _openssl_mutexes = NULL; _n_openssl_mutexes = 0; + for (i=0;i<n;++i) { + tor_mutex_free(ms[i]); + } + tor_free(ms); } #endif return 0; @@ -1649,6 +1652,11 @@ secret_to_key(char *key_out, size_t key_out_len, const char *secret, static void _openssl_locking_cb(int mode, int n, const char *file, int line) { + if (!_openssl_mutexes) + /* This is not a really good fix for the + * "release-freed-lock-from-separate-thread-on-shutdown" problem, but + * it can't hurt. */ + return; if (mode & CRYPTO_LOCK) tor_mutex_acquire(_openssl_mutexes[n]); else |