[or-cvs] Per comments at the bottom of openssl/FAQ, call even more f...

Nick Mathewson nickm at seul.org
Tue Oct 25 19:01:50 UTC 2005


Update of /home/or/cvsroot/tor/src/common
In directory moria:/tmp/cvs-serv8763/common

Modified Files:
	crypto.c crypto.h 
Log Message:
Per comments at the bottom of openssl/FAQ, call even more functions to
clean up OpenSSL's toys when it's done playing.  (Why isn't there an
OpenSSL_free_everything() function?)



Index: crypto.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/crypto.c,v
retrieving revision 1.170
retrieving revision 1.171
diff -u -d -r1.170 -r1.171
--- crypto.c	18 Oct 2005 21:58:19 -0000	1.170
+++ crypto.c	25 Oct 2005 19:01:48 -0000	1.171
@@ -32,6 +32,7 @@
 #include <openssl/dh.h>
 #include <openssl/rsa.h>
 #include <openssl/dh.h>
+#include <openssl/conf.h>
 
 #include <stdlib.h>
 #include <assert.h>
@@ -220,16 +221,26 @@
   return 0;
 }
 
+/** Free crypto resources held by this thread. */
+void
+crypto_thread_cleanup(void)
+{
+  ERR_remove_state(0);
+}
+
 /** Uninitialize the crypto library. Return 0 on success, -1 on failure.
  */
 int
 crypto_global_cleanup(void)
 {
   EVP_cleanup();
+  //ERR_remove_state(0);
   ERR_free_strings();
 #ifndef NO_ENGINES
   ENGINE_cleanup();
 #endif
+  CONF_modules_unload(1);
+  CRYPTO_cleanup_all_ex_data();
 #ifdef TOR_IS_MULTITHREADED
   if (_n_openssl_mutexes) {
     int n = _n_openssl_mutexes;

Index: crypto.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/crypto.h,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- crypto.h	6 Oct 2005 22:18:01 -0000	1.68
+++ crypto.h	25 Oct 2005 19:01:48 -0000	1.69
@@ -53,6 +53,7 @@
 
 /* global state */
 int crypto_global_init(int hardwareAccel);
+void crypto_thread_cleanup(void);
 int crypto_global_cleanup(void);
 
 /* environment setup */



More information about the tor-commits mailing list