cvs: pecl /http http_request_api.c

From: Date: Thu, 07 Dec 2006 10:11:36 +0000
Subject: cvs: pecl /http http_request_api.c
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-6760@lists.php.net to get a copy of this message
mike Thu Dec 7 10:11:36 2006 UTC Modified files: /pecl/http http_request_api.c Log: - check CRYPTO_get_id_callback() whether someone else already set thread lock callbacks # this might also be of interest to ext/curl http://cvs.php.net/viewvc.cgi/pecl/http/http_request_api.c?r1=1.143&r2=1.144&diff_format=u Index: pecl/http/http_request_api.c diff -u pecl/http/http_request_api.c:1.143 pecl/http/http_request_api.c:1.144 --- pecl/http/http_request_api.c:1.143 Mon Nov 20 11:15:06 2006 +++ pecl/http/http_request_api.c Thu Dec 7 10:11:36 2006 @@ -10,7 +10,7 @@ +--------------------------------------------------------------------+ */ -/* $Id: http_request_api.c,v 1.143 2006/11/20 11:15:06 mike Exp $ */ +/* $Id: http_request_api.c,v 1.144 2006/12/07 10:11:36 mike Exp $ */ #define HTTP_WANT_SAPI #define HTTP_WANT_CURL @@ -87,16 +87,19 @@ PHP_MINIT_FUNCTION(http_request) { #ifdef HTTP_NEED_OPENSSL_TSL - int i, c = CRYPTO_num_locks(); - - http_openssl_tsl = malloc(c * sizeof(MUTEX_T)); - - for (i = 0; i < c; ++i) { - http_openssl_tsl[i] = tsrm_mutex_alloc(); + /* mod_ssl, libpq or ext/curl might already have set thread lock callbacks */ + if (!CRYPTO_get_id_callback()) { + int i, c = CRYPTO_num_locks(); + + http_openssl_tsl = malloc(c * sizeof(MUTEX_T)); + + for (i = 0; i < c; ++i) { + http_openssl_tsl[i] = tsrm_mutex_alloc(); + } + + CRYPTO_set_id_callback(http_openssl_thread_id); + CRYPTO_set_locking_callback(http_openssl_thread_lock); } - - CRYPTO_set_id_callback(http_openssl_thread_id); - CRYPTO_set_locking_callback(http_openssl_thread_lock); #endif #ifdef HTTP_NEED_GNUTLS_TSL gcry_control(GCRYCTL_SET_THREAD_CBS, &http_gnutls_tsl); @@ -138,10 +141,6 @@ /* {{{ MSHUTDOWN */ PHP_MSHUTDOWN_FUNCTION(http_request) { -#ifdef HTTP_NEED_OPENSSL_TSL - CRYPTO_set_id_callback(http_openssl_thread_id); - CRYPTO_set_locking_callback(http_openssl_thread_lock); -#endif curl_global_cleanup(); #ifdef HTTP_NEED_OPENSSL_TSL if (http_openssl_tsl) {

« previous php.pecl.cvs (#6760) next »