X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_curl.c;h=65b1746b8f7b38ac7a71f71c584d49fe108c3b44;hp=5e588283570d87fd64e53df8c5abf5e130ac422a;hb=517336efe27e1f8e58e36352478a6d9ffdcdf378;hpb=29a54250b58e444974ae19840194e214cab80bd5 diff --git a/php_http_curl.c b/php_http_curl.c index 5e58828..65b1746 100644 --- a/php_http_curl.c +++ b/php_http_curl.c @@ -21,9 +21,6 @@ # include #endif -#include - - typedef struct php_http_curl_request { CURL *handle; @@ -64,19 +61,8 @@ typedef struct php_http_curl_request_pool { #endif } php_http_curl_request_pool_t; -#ifdef ZTS -typedef struct php_http_curl_request_datashare_lock { - CURL *ch; - MUTEX_T mx; -} php_http_curl_request_datashare_lock_t; -#endif - typedef struct php_http_curl_request_datashare { CURLSH *handle; - -#ifdef ZTS - php_http_curl_request_datashare_lock_t *locks; -#endif } php_http_curl_request_datashare_t; #define PHP_HTTP_CURL_OPT_STRING(OPTION, ldiff, obdc) \ @@ -141,6 +127,7 @@ static void *php_http_curl_copy(void *opaque, void *handle TSRMLS_DC) void *ch; if ((ch = curl_easy_duphandle(handle))) { + curl_easy_reset(ch); get_storage(ch); return ch; } @@ -512,6 +499,7 @@ static int php_http_curl_request_pool_socket_callback(CURL *easy, curl_socket_t case CURL_POLL_REMOVE: efree(ev); + /* no break */ case CURL_POLL_NONE: return 0; @@ -1150,53 +1138,6 @@ static STATUS get_info(CURL *ch, HashTable *info) } -#ifdef ZTS -static void *php_http_curl_request_datashare_locks_init(void) -{ - int i; - php_http_curl_request_datashare_lock_t *locks = pecalloc(CURL_LOCK_DATA_LAST, sizeof(*locks), 1); - - if (locks) { - for (i = 0; i < CURL_LOCK_DATA_LAST; ++i) { - locks[i].mx = tsrm_mutex_alloc(); - } - } - - return locks; -} - -static void php_http_curl_request_datashare_locks_dtor(void *l) -{ - int i; - php_http_curl_request_datashare_lock_t *locks = l; - - for (i = 0; i < CURL_LOCK_DATA_LAST; ++i) { - tsrm_mutex_free(locks[i].mx); - } - pefree(locks, 1); -} - -static void php_http_curl_request_datashare_lock_func(CURL *handle, curl_lock_data data, curl_lock_access locktype, void *userptr) -{ - php_http_curl_request_datashare_lock_t *locks = userptr; - - /* TSRM can't distinguish shared/exclusive locks */ - tsrm_mutex_lock(locks[data].mx); - locks[data].ch = handle; -} - -static void php_http_curl_request_datashare_unlock_func(CURL *handle, curl_lock_data data, void *userptr) -{ - php_http_curl_request_datashare_lock_t *locks = userptr; - - if (locks[data].ch == handle) { - tsrm_mutex_unlock(locks[data].mx); - } -} -#endif - - - /* request datashare handler ops */ static php_http_request_datashare_t *php_http_curl_request_datashare_init(php_http_request_datashare_t *h, void *handle) @@ -1209,18 +1150,8 @@ static php_http_request_datashare_t *php_http_curl_request_datashare_init(php_ht return NULL; } - curl = pecalloc(1, sizeof(*curl), h->persistent); + curl = ecalloc(1, sizeof(*curl)); curl->handle = handle; -#ifdef ZTS - if (h->persistent) { - curl->locks = php_http_curl_request_datashare_locks_init(); - if (curl->locks) { - curl_share_setopt(curl->handle, CURLSHOPT_LOCKFUNC, php_http_curl_request_datashare_lock_func); - curl_share_setopt(curl->handle, CURLSHOPT_UNLOCKFUNC, php_http_curl_request_datashare_unlock_func); - curl_share_setopt(curl->handle, CURLSHOPT_USERDATA, curl->locks); - } - } -#endif h->ctx = curl; return h; @@ -1233,13 +1164,7 @@ static void php_http_curl_request_datashare_dtor(php_http_request_datashare_t *h php_http_resource_factory_handle_dtor(h->rf, curl->handle TSRMLS_CC); -#ifdef ZTS - if (h->persistent) { - php_http_curl_request_datashare_locks_dtor(curl->locks); - } -#endif - - pefree(curl, h->persistent); + efree(curl); h->ctx = NULL; } @@ -1287,7 +1212,7 @@ static STATUS php_http_curl_request_datashare_setopt(php_http_request_datashare_ break; case PHP_HTTP_REQUEST_DATASHARE_OPT_RESOLVER: - if (CURLSHE_OK != (rc = curl_share_setopt(curl->handle, *((zend_bool *) arg) ? CURLSHOPT_SHARE : CURLSHOPT_UNSHARE, CURL_LOCK_DATA_COOKIE))) { + if (CURLSHE_OK != (rc = curl_share_setopt(curl->handle, *((zend_bool *) arg) ? CURLSHOPT_SHARE : CURLSHOPT_UNSHARE, CURL_LOCK_DATA_DNS))) { TSRMLS_FETCH_FROM_CTX(h->ts); php_http_error(HE_WARNING, PHP_HTTP_E_REQUEST_DATASHARE, "Could not %s sharing of resolver data: %s", *((zend_bool *) arg) ? "enable" : "disable", curl_share_strerror(rc));