fix more race conditions
[openssl.git] / ssl / t1_meth.c
index 9bb36a7..fcc243f 100644 (file)
@@ -76,13 +76,21 @@ SSL_METHOD *TLSv1_method(void)
 
        if (init)
                {
-               memcpy((char *)&TLSv1_data,(char *)tlsv1_base_method(),
-                       sizeof(SSL_METHOD));
-               TLSv1_data.ssl_connect=ssl3_connect;
-               TLSv1_data.ssl_accept=ssl3_accept;
-               TLSv1_data.get_ssl_method=tls1_get_method;
-               init=0;
+               CRYPTO_w_lock(CRYPTO_LOCK_SSL_METHOD);
+               
+               if (init)
+                       {
+                       memcpy((char *)&TLSv1_data,(char *)tlsv1_base_method(),
+                               sizeof(SSL_METHOD));
+                       TLSv1_data.ssl_connect=ssl3_connect;
+                       TLSv1_data.ssl_accept=ssl3_accept;
+                       TLSv1_data.get_ssl_method=tls1_get_method;
+                       init=0;
+                       }
+
+               CRYPTO_w_unlock(CRYPTO_LOCK_SSL_METHOD);
                }
+       
        return(&TLSv1_data);
        }