Преглед изворни кода

tls: remove thread-enablement on EVP_RAND_CTX

- with late initialisation it is not necessary to enable thread locking
  on EVP_RAND_CTX
- the function remains but is not used in case requirements change
  with OpenSSL >= 3.2

(cherry-pick from 8dffc45ee91aeed839efb38d17040359dcac953a)
S-P Chan пре 1 година
родитељ
комит
bbbcb27040
1 измењених фајлова са 15 додато и 2 уклоњено
  1. 15 2
      src/modules/tls/tls_init.c

+ 15 - 2
src/modules/tls/tls_init.c

@@ -731,6 +731,12 @@ int tls_pre_init(void)
  * - executed before any mod_init()
  * - executed before any mod_init()
  */
  */
 #if OPENSSL_VERSION_NUMBER >= 0x030000000L
 #if OPENSSL_VERSION_NUMBER >= 0x030000000L
+/*
+ * With late initialisation it is not necessary to
+ * enable threading on the EVP_RAND_CTX. This function
+ * left here in case more complex requirements arise in
+ * OpenSSL >= 3.2.
+ */
 long tls_h_mod_randctx(void *) {
 long tls_h_mod_randctx(void *) {
     do {
     do {
         OSSL_LIB_CTX *osslglobal = NULL;
         OSSL_LIB_CTX *osslglobal = NULL;
@@ -768,7 +774,7 @@ long tls_h_mod_randctx(void *) {
 
 
     return 0L;
     return 0L;
 }
 }
-#endif
+#endif /* OPENSSL_VERSION_NUMBER */
 
 
 int tls_h_mod_pre_init_f(void)
 int tls_h_mod_pre_init_f(void)
 {
 {
@@ -794,14 +800,21 @@ int tls_h_mod_pre_init_f(void)
 	SSL_load_error_strings();
 	SSL_load_error_strings();
 #endif
 #endif
 
 
+#if 0
 #if OPENSSL_VERSION_NUMBER >= 0x030000000L
 #if OPENSSL_VERSION_NUMBER >= 0x030000000L
+        /*
+         * With deferred initialisation it is not necessary to enable threading
+         * on the EVP_RAND_CTX. We leave this block here as an example of how
+         * to do it in case of future requirements.
+         */
         pthread_t tid;
         pthread_t tid;
         long rl;
         long rl;
         pthread_create(&tid, NULL, (void *(*)(void *))tls_h_mod_randctx, NULL);
         pthread_create(&tid, NULL, (void *(*)(void *))tls_h_mod_randctx, NULL);
         pthread_join(tid, (void **)&rl);
         pthread_join(tid, (void **)&rl);
         if ((int)rl)
         if ((int)rl)
             return (int)rl;
             return (int)rl;
-#endif
+#endif /* OPENSSL_VERSION_NUMBER */
+#endif /* 0 */
 
 
 	tls_mod_preinitialized = 1;
 	tls_mod_preinitialized = 1;
 	return 0;
 	return 0;