Fix i2d_X509_AUX, update docs and add tests
[openssl.git] / crypto / init.c
index d9f40001a2491a798d0304bb258377e1df4d80db..938bf78a39cef71b34e12e2ed14a515c6fc57b21 100644 (file)
@@ -67,6 +67,7 @@
 #include <internal/engine.h>
 #include <internal/comp.h>
 #include <internal/err.h>
+#include <internal/err_int.h>
 #include <internal/objects.h>
 #include <stdlib.h>
 #include <assert.h>
@@ -350,9 +351,9 @@ static void ossl_init_thread_stop(struct thread_local_inits_st *locals)
     if (locals->err_state) {
 #ifdef OPENSSL_INIT_DEBUG
         fprintf(stderr, "OPENSSL_INIT: ossl_init_thread_stop: "
-                        "ERR_remove_thread_state()\n");
+                        "err_delete_thread_state()\n");
 #endif
-        ERR_remove_thread_state();
+        err_delete_thread_state();
     }
 
     OPENSSL_free(locals);
@@ -466,19 +467,25 @@ void OPENSSL_cleanup(void)
                     "crypto_cleanup_all_ex_data_int()\n");
     fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
                     "bio_sock_cleanup_int()\n");
+    fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
+                    "bio_cleanup()\n");
     fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
                     "evp_cleanup_int()\n");
     fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
                     "obj_cleanup_int()\n");
+    fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
+                    "err_cleanup()\n");
 #endif
     /*
      * Note that cleanup order is important:
-     * - rand_cleanup_int could call an ENINGE's RAND cleanup function so
+     * - rand_cleanup_int could call an ENGINE's RAND cleanup function so
      * must be called before engine_cleanup_int()
      * - ENGINEs use CRYPTO_EX_DATA and therefore, must be cleaned up
      * before the ex data handlers are wiped in CRYPTO_cleanup_all_ex_data().
      * - conf_modules_free_int() can end up in ENGINE code so must be called
      * before engine_cleanup_int()
+     * - ENGINEs and additional EVP algorithms might use added OIDs names so
+     * obj_cleanup_int() must be called last
      */
     rand_cleanup_int();
     conf_modules_free_int();
@@ -486,11 +493,11 @@ void OPENSSL_cleanup(void)
     engine_cleanup_int();
 #endif
     crypto_cleanup_all_ex_data_int();
-#ifndef OPENSSL_NO_SOCK
-    bio_sock_cleanup_int();
-#endif
+    bio_cleanup();
     evp_cleanup_int();
     obj_cleanup_int();
+    err_cleanup();
+
     base_inited = 0;
 }