[or-cvs] Try to make crash-on-shutdown bug harder to trigger.

Nick Mathewson nickm at seul.org
Fri Apr 1 02:37:13 UTC 2005


Update of /home/or/cvsroot/tor/src/common
In directory moria.mit.edu:/tmp/cvs-serv10191/src/common

Modified Files:
	crypto.c 
Log Message:
Try to make crash-on-shutdown bug harder to trigger.

Index: crypto.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/crypto.c,v
retrieving revision 1.134
retrieving revision 1.135
diff -u -d -r1.134 -r1.135
--- crypto.c	23 Mar 2005 06:20:50 -0000	1.134
+++ crypto.c	1 Apr 2005 02:37:10 -0000	1.135
@@ -177,12 +177,15 @@
   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 @@
 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



More information about the tor-commits mailing list