Forráskód Böngészése

Do not call CRYPTO_cleanup_all_ex_data for every thread ... again.

This commit undoes commit f8709d6caf51278e60353227aad1a6203419a9e1 (Issue #263)

According to the OpenSSL-Documentation https://wiki.openssl.org/index.php/Library_Initialization#Cleanup:

"CRYPTO_cleanup_all_ex_data and ERR_remove_state should be called on each thread, and not just the main thread."

The CRYPTO_cleanup_all_ex_data for every thread have been added with the commit f8709d6caf51278e60353227aad1a6203419a9e1.
However, since then there are some sporadic crashes in the automatic tests.

Checking the discussion page of this documentation (https://wiki.openssl.org/index.php/Talk:Library_Initialization):

You said: "CRYPTO_cleanup_all_ex_data and ERR_remove_state should be called on each thread, and not just the main thread."

However the FAQ says:

> "Brutal" (thread-unsafe) Application-global cleanup functions:
>
>  ERR_free_strings(), EVP_cleanup() and CRYPTO_cleanup_all_ex_data().'
>
> And the code comments for CRYPTO_cleanup_all_ex_data() say:
>
>/* Release all "ex_data" state to prevent memory leaks. This can't be made
> * thread-safe without overhauling a lot of stuff, and shouldn't really be
> * called under potential race-conditions anyway (it's for program shutdown
> * after all). */
>
>So I don't think its right to say CRYPTO_cleanup_all_ex_data() should be called on each thread. >--Matt (talk) 14:30, 7 May 2015 (UTC)

... So, this commit removes the extra CRYPTO_cleanup_all_ex_data again.

Let's see if the crashes in the CI tests are gone ...
bel 9 éve
szülő
commit
da7f6c3943
1 módosított fájl, 6 hozzáadás és 3 törlés
  1. 6 3
      src/civetweb.c

+ 6 - 3
src/civetweb.c

@@ -10528,7 +10528,8 @@ sslize(struct mg_connection *conn, SSL_CTX *s, int (*func)(SSL *))
 		(void)err; /* TODO: set some error message */
 		SSL_free(conn->ssl);
 		conn->ssl = NULL;
-		CRYPTO_cleanup_all_ex_data();
+		/* maybe not? CRYPTO_cleanup_all_ex_data(); */
+		/* see https://wiki.openssl.org/index.php/Talk:Library_Initialization */
 		ERR_remove_state(0);
 		return 0;
 	}
@@ -10539,7 +10540,8 @@ sslize(struct mg_connection *conn, SSL_CTX *s, int (*func)(SSL *))
 		(void)err; /* TODO: set some error message */
 		SSL_free(conn->ssl);
 		conn->ssl = NULL;
-		CRYPTO_cleanup_all_ex_data();
+		/* maybe not? CRYPTO_cleanup_all_ex_data(); */
+		/* see https://wiki.openssl.org/index.php/Talk:Library_Initialization */
 		ERR_remove_state(0);
 		return 0;
 	}
@@ -11101,7 +11103,8 @@ close_connection(struct mg_connection *conn)
 		 */
 		SSL_shutdown(conn->ssl);
 		SSL_free(conn->ssl);
-		CRYPTO_cleanup_all_ex_data();
+		/* maybe not? CRYPTO_cleanup_all_ex_data(); */
+		/* see https://wiki.openssl.org/index.php/Talk:Library_Initialization */
 		ERR_remove_state(0);
 		conn->ssl = NULL;
 	}