From a4fd0a809ae831f21cbaec14e24c3d3ee0569c12 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Wed, 1 Feb 2012 09:23:26 +0000 Subject: [PATCH] remove that awkward and error prone global request datashare --- php_http.c | 7 --- php_http_api.h | 1 - php_http_curl.c | 80 +------------------------ php_http_request.c | 4 -- php_http_request.h | 1 - php_http_request_datashare.c | 113 +++++------------------------------ php_http_request_datashare.h | 17 +----- php_http_request_factory.c | 46 +------------- php_http_request_pool.c | 4 -- php_http_request_pool.h | 2 - tests/factory.phpt | 25 ++++++-- 11 files changed, 41 insertions(+), 259 deletions(-) diff --git a/php_http.c b/php_http.c index 889cb09..2cd6549 100644 --- a/php_http.c +++ b/php_http.c @@ -119,10 +119,6 @@ zend_php_http_globals *php_http_globals(void) #endif PHP_INI_BEGIN() PHP_HTTP_INI_ENTRY("http.etag.mode", "crc32b", PHP_INI_ALL, OnUpdateString, env.etag_mode) - PHP_HTTP_INI_ENTRY("http.request_datashare.cookie", "0", PHP_INI_SYSTEM, OnUpdateBool, request_datashare.cookie) - PHP_HTTP_INI_ENTRY("http.request_datashare.dns", "1", PHP_INI_SYSTEM, OnUpdateBool, request_datashare.dns) - PHP_HTTP_INI_ENTRY("http.request_datashare.ssl", "0", PHP_INI_SYSTEM, OnUpdateBool, request_datashare.ssl) - PHP_HTTP_INI_ENTRY("http.request_datashare.connect", "0", PHP_INI_SYSTEM, OnUpdateBool, request_datashare.connect) PHP_HTTP_INI_ENTRY("http.persistent_handle.limit", "-1", PHP_INI_SYSTEM, OnUpdateLong, persistent_handle.limit) PHP_INI_END() @@ -174,7 +170,6 @@ PHP_MSHUTDOWN_FUNCTION(http) #if PHP_HTTP_HAVE_CURL || SUCCESS != PHP_MSHUTDOWN_CALL(http_curl) #endif - || SUCCESS != PHP_MSHUTDOWN_CALL(http_request_datashare) || SUCCESS != PHP_MSHUTDOWN_CALL(http_request_factory) || SUCCESS != PHP_MSHUTDOWN_CALL(http_persistent_handle) ) { @@ -188,7 +183,6 @@ PHP_RINIT_FUNCTION(http) { if (0 || SUCCESS != PHP_RINIT_CALL(http_env) - || SUCCESS != PHP_RINIT_CALL(http_request_datashare) #if PHP_HTTP_HAVE_CURL || SUCCESS != PHP_RINIT_CALL(http_curl) #endif @@ -203,7 +197,6 @@ PHP_RSHUTDOWN_FUNCTION(http) { if (0 || SUCCESS != PHP_RSHUTDOWN_CALL(http_env) - || SUCCESS != PHP_RSHUTDOWN_CALL(http_request_datashare) ) { return FAILURE; } diff --git a/php_http_api.h b/php_http_api.h index ebb6218..50ff615 100644 --- a/php_http_api.h +++ b/php_http_api.h @@ -106,7 +106,6 @@ typedef int STATUS; ZEND_BEGIN_MODULE_GLOBALS(php_http) struct php_http_env_globals env; struct php_http_persistent_handle_globals persistent_handle; - struct php_http_request_datashare_globals request_datashare; #if PHP_HTTP_HAVE_CURL && PHP_HTTP_HAVE_EVENT struct php_http_curl_globals curl; #endif diff --git a/php_http_curl.c b/php_http_curl.c index 91b476c..2d10922 100644 --- a/php_http_curl.c +++ b/php_http_curl.c @@ -61,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) \ @@ -1148,53 +1137,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) @@ -1207,18 +1149,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; @@ -1231,13 +1163,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; } @@ -1285,7 +1211,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)); diff --git a/php_http_request.c b/php_http_request.c index 26e87f6..b22e12e 100644 --- a/php_http_request.c +++ b/php_http_request.c @@ -52,10 +52,6 @@ PHP_HTTP_API void php_http_request_dtor(php_http_request_t *h) php_http_resource_factory_free(&h->rf); - if (h->persistent_handle_id) { - zval_ptr_dtor(&h->persistent_handle_id); - } - php_http_message_parser_free(&h->parser); php_http_message_free(&h->message); php_http_buffer_free(&h->buffer); diff --git a/php_http_request.h b/php_http_request.h index 6c0c0c9..3d7b78c 100644 --- a/php_http_request.h +++ b/php_http_request.h @@ -150,7 +150,6 @@ struct php_http_request { php_http_message_parser_t *parser; php_http_message_t *message; php_http_buffer_t *buffer; - zval *persistent_handle_id; #ifdef ZTS void ***ts; #endif diff --git a/php_http_request_datashare.c b/php_http_request_datashare.c index ce3f1a3..a4502e5 100644 --- a/php_http_request_datashare.c +++ b/php_http_request_datashare.c @@ -16,61 +16,24 @@ static int php_http_request_datashare_compare_handles(void *h1, void *h2); -#ifdef ZTS -static void *php_http_request_datashare_locks_init(void); -static void php_http_request_datashare_locks_dtor(void *l); -static void php_http_request_datashare_lock_func(CURL *handle, curl_lock_data data, curl_lock_access locktype, void *userptr); -static void php_http_request_datashare_unlock_func(CURL *handle, curl_lock_data data, void *userptr); -static MUTEX_T php_http_request_datashare_global_shares_lock; -#endif -static HashTable php_http_request_datashare_global_shares; -php_http_request_datashare_t *php_http_request_datashare_global_get(const char *driver_str, size_t driver_len TSRMLS_DC) -{ - php_http_request_datashare_t *s = NULL, **s_ptr; - char *lower_str = php_strtolower(estrndup(driver_str, driver_len), driver_len); - -#ifdef ZTS - tsrm_mutex_lock(php_http_request_datashare_global_shares_lock); -#endif - if (zend_hash_find(&php_http_request_datashare_global_shares, lower_str, driver_len + 1, (void *) &s_ptr)) { - s = *s_ptr; - } else { - php_http_request_factory_driver_t driver; - - if ((SUCCESS == php_http_request_factory_get_driver(driver_str, driver_len, &driver)) && driver.request_datashare_ops) { - s = php_http_request_datashare_init(NULL, driver.request_datashare_ops, NULL, NULL, 1 TSRMLS_CC); - zend_hash_add(&php_http_request_datashare_global_shares, lower_str, driver_len + 1, &s, sizeof(php_http_request_datashare_t *), NULL); - } - } -#ifdef ZTS - tsrm_mutex_unlock(php_http_request_datashare_global_shares_lock); -#endif - - efree(lower_str); - return s; -} - -PHP_HTTP_API php_http_request_datashare_t *php_http_request_datashare_init(php_http_request_datashare_t *h, php_http_request_datashare_ops_t *ops, php_http_resource_factory_t *rf, void *init_arg, zend_bool persistent TSRMLS_DC) +PHP_HTTP_API php_http_request_datashare_t *php_http_request_datashare_init(php_http_request_datashare_t *h, php_http_request_datashare_ops_t *ops, php_http_resource_factory_t *rf, void *init_arg TSRMLS_DC) { php_http_request_datashare_t *free_h = NULL; if (!h) { - free_h = h = pemalloc(sizeof(*h), persistent); + free_h = h = emalloc(sizeof(*h)); } memset(h, sizeof(*h), 0); - if (!(h->persistent = persistent)) { - h->requests = emalloc(sizeof(*h->requests)); - zend_llist_init(h->requests, sizeof(zval *), ZVAL_PTR_DTOR, 0); - TSRMLS_SET_CTX(h->ts); - } + zend_llist_init(&h->requests, sizeof(zval *), ZVAL_PTR_DTOR, 0); h->ops = ops; h->rf = rf ? rf : php_http_resource_factory_init(NULL, h->ops->rsrc, NULL, NULL); + TSRMLS_SET_CTX(h->ts); if (h->ops->init) { if (!(h = h->ops->init(h, init_arg))) { if (free_h) { - pefree(free_h, persistent); + efree(free_h); } } } @@ -92,21 +55,14 @@ PHP_HTTP_API void php_http_request_datashare_dtor(php_http_request_datashare_t * if (h->ops->dtor) { h->ops->dtor(h); } - if (h->requests) { - zend_llist_destroy(h->requests); - pefree(h->requests, h->persistent); - h->requests = NULL; - } - - if (h->persistent_handle_id) { - zval_ptr_dtor(&h->persistent_handle_id); - } + zend_llist_destroy(&h->requests); + php_http_resource_factory_free(&h->rf); } PHP_HTTP_API void php_http_request_datashare_free(php_http_request_datashare_t **h) { php_http_request_datashare_dtor(*h); - pefree(*h, (*h)->persistent); + efree(*h); *h = NULL; } @@ -119,7 +75,7 @@ PHP_HTTP_API STATUS php_http_request_datashare_attach(php_http_request_datashare if (SUCCESS == h->ops->attach(h, obj->request)) { Z_ADDREF_P(request); - zend_llist_add_element(PHP_HTTP_REQUEST_DATASHARE_REQUESTS(h), &request); + zend_llist_add_element(&h->requests, &request); return SUCCESS; } } @@ -140,7 +96,7 @@ PHP_HTTP_API STATUS php_http_request_datashare_detach(php_http_request_datashare php_http_request_object_t *obj = zend_object_store_get_object(request TSRMLS_CC); if (SUCCESS == h->ops->detach(h, obj->request)) { - zend_llist_del_element(PHP_HTTP_REQUEST_DATASHARE_REQUESTS(h), request, php_http_request_datashare_compare_handles); + zend_llist_del_element(&h->requests, request, php_http_request_datashare_compare_handles); return SUCCESS; } } @@ -167,16 +123,10 @@ PHP_HTTP_API void php_http_request_datashare_reset(php_http_request_datashare_t if (h->ops->reset) { h->ops->reset(h); } else if (h->ops->detach) { - zend_llist_apply_with_argument(PHP_HTTP_REQUEST_DATASHARE_REQUESTS(h), detach, h TSRMLS_CC); + zend_llist_apply_with_argument(&h->requests, detach, h TSRMLS_CC); } - zend_llist_clean(PHP_HTTP_REQUEST_DATASHARE_REQUESTS(h)); -} - -static void php_http_request_datashare_global_requests_dtor(void *el) -{ - //php_http_request_datashare_detach(php_http_request_datashare_global_get(), *((zval **) el)); - zval_ptr_dtor(el); + zend_llist_clean(&h->requests); } #define PHP_HTTP_BEGIN_ARGS(method, req_args) PHP_HTTP_BEGIN_ARGS_EX(HttpRequestDataShare, method, 0, req_args) @@ -227,7 +177,7 @@ zend_object_value php_http_request_datashare_object_new_ex(zend_class_entry *ce, if (share) { o->share = share; } else { - o->share = php_http_request_datashare_init(NULL, NULL, NULL, NULL, 0 TSRMLS_CC); + o->share = php_http_request_datashare_init(NULL, NULL, NULL, NULL TSRMLS_CC); } if (ptr) { @@ -244,9 +194,7 @@ void php_http_request_datashare_object_free(void *object TSRMLS_DC) { php_http_request_datashare_object_t *o = (php_http_request_datashare_object_t *) object; - if (!o->share->persistent) { - php_http_request_datashare_free(&o->share); - } + php_http_request_datashare_free(&o->share); zend_object_std_dtor((zend_object *) o TSRMLS_CC); efree(o); } @@ -311,7 +259,7 @@ PHP_METHOD(HttpRequestDataShare, count) if (SUCCESS == zend_parse_parameters_none()) { php_http_request_datashare_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC); - RETURN_LONG(zend_llist_count(PHP_HTTP_REQUEST_DATASHARE_REQUESTS(obj->share))); + RETURN_LONG(zend_llist_count(&obj->share->requests)); } RETURN_FALSE; } @@ -364,43 +312,12 @@ PHP_MINIT_FUNCTION(http_request_datashare) zend_class_implements(php_http_request_datashare_class_entry TSRMLS_CC, 1, spl_ce_Countable); - zend_declare_property_null(php_http_request_datashare_class_entry, ZEND_STRL("instance"), (ZEND_ACC_STATIC|ZEND_ACC_PRIVATE) TSRMLS_CC); zend_declare_property_bool(php_http_request_datashare_class_entry, ZEND_STRL("cookie"), 0, ZEND_ACC_PUBLIC TSRMLS_CC); zend_declare_property_bool(php_http_request_datashare_class_entry, ZEND_STRL("dns"), 0, ZEND_ACC_PUBLIC TSRMLS_CC); -#ifdef ZTS - php_http_request_datashare_global_shares_lock = tsrm_mutex_alloc(); -#endif - zend_hash_init(&php_http_request_datashare_global_shares, 0, NULL, (dtor_func_t) php_http_request_datashare_free, 1); - return SUCCESS; } -PHP_MSHUTDOWN_FUNCTION(http_request_datashare) -{ - zend_hash_destroy(&php_http_request_datashare_global_shares); -#ifdef ZTS - tsrm_mutex_free(php_http_request_datashare_global_shares_lock); -#endif - - return SUCCESS; -} - -PHP_RINIT_FUNCTION(http_request_datashare) -{ - zend_llist_init(&PHP_HTTP_G->request_datashare.requests, sizeof(zval *), php_http_request_datashare_global_requests_dtor, 0); - - return SUCCESS; -} - -PHP_RSHUTDOWN_FUNCTION(http_request_datashare) -{ - zend_llist_destroy(&PHP_HTTP_G->request_datashare.requests); - - return SUCCESS; -} - - /* * Local variables: * tab-width: 4 diff --git a/php_http_request_datashare.h b/php_http_request_datashare.h index 5ef6328..a6939ac 100644 --- a/php_http_request_datashare.h +++ b/php_http_request_datashare.h @@ -39,35 +39,22 @@ typedef struct php_http_request_datashare_ops { php_http_request_datashare_setopt_func_t setopt; } php_http_request_datashare_ops_t; -#define PHP_HTTP_REQUEST_DATASHARE_REQUESTS(s) ((s)->persistent ? &PHP_HTTP_G->request_datashare.requests : (s)->requests) struct php_http_request_datashare { void *ctx; php_http_resource_factory_t *rf; php_http_request_datashare_ops_t *ops; - zend_llist *requests; /* NULL if persistent, use PHP_HTTP_REQUEST_DATASHARE_REQUESTS */ - unsigned persistent:1; - zval *persistent_handle_id; + zend_llist requests; #ifdef ZTS void ***ts; #endif }; -struct php_http_request_datashare_globals { - zend_llist requests; - zend_bool cookie; - zend_bool dns; - zend_bool ssl; - zend_bool connect; -}; - -extern php_http_request_datashare_t *php_http_request_datashare_global_get(const char *driver_str, size_t driver_len TSRMLS_DC); - extern PHP_MINIT_FUNCTION(http_request_datashare); extern PHP_MSHUTDOWN_FUNCTION(http_request_datashare); extern PHP_RINIT_FUNCTION(http_request_datashare); extern PHP_RSHUTDOWN_FUNCTION(http_request_datashare); -PHP_HTTP_API php_http_request_datashare_t *php_http_request_datashare_init(php_http_request_datashare_t *h, php_http_request_datashare_ops_t *ops, php_http_resource_factory_t *rf, void *init_arg, zend_bool persistent TSRMLS_DC); +PHP_HTTP_API php_http_request_datashare_t *php_http_request_datashare_init(php_http_request_datashare_t *h, php_http_request_datashare_ops_t *ops, php_http_resource_factory_t *rf, void *init_arg TSRMLS_DC); PHP_HTTP_API php_http_request_datashare_t *php_http_request_datashare_copy(php_http_request_datashare_t *from, php_http_request_datashare_t *to); PHP_HTTP_API void php_http_request_datashare_dtor(php_http_request_datashare_t *h); PHP_HTTP_API void php_http_request_datashare_free(php_http_request_datashare_t **h); diff --git a/php_http_request_factory.c b/php_http_request_factory.c index b1655f6..1f5f241 100644 --- a/php_http_request_factory.c +++ b/php_http_request_factory.c @@ -73,7 +73,6 @@ PHP_HTTP_BEGIN_ARGS(createDataShare, 0) PHP_HTTP_ARG_OBJ(http\\Request, request2, 1) PHP_HTTP_ARG_OBJ(http\\Request, requestN, 1) PHP_HTTP_END_ARGS; -PHP_HTTP_EMPTY_ARGS(getGlobalDataShareInstance); PHP_HTTP_EMPTY_ARGS(getDriver); PHP_HTTP_EMPTY_ARGS(getAvailableDrivers); @@ -83,7 +82,6 @@ zend_function_entry php_http_request_factory_method_entry[] = { PHP_HTTP_REQUEST_FACTORY_ME(createRequest, ZEND_ACC_PUBLIC) PHP_HTTP_REQUEST_FACTORY_ME(createPool, ZEND_ACC_PUBLIC) PHP_HTTP_REQUEST_FACTORY_ME(createDataShare, ZEND_ACC_PUBLIC) - PHP_HTTP_REQUEST_FACTORY_ME(getGlobalDataShareInstance, ZEND_ACC_PUBLIC) PHP_HTTP_REQUEST_FACTORY_ME(getDriver, ZEND_ACC_PUBLIC) PHP_HTTP_REQUEST_FACTORY_ME(getAvailableDrivers, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) @@ -305,7 +303,7 @@ PHP_METHOD(HttpRequestFactory, createDataShare) efree(name_str); } - share = php_http_request_datashare_init(NULL, driver.request_datashare_ops, rf, NULL, 0 TSRMLS_CC); + share = php_http_request_datashare_init(NULL, driver.request_datashare_ops, rf, NULL TSRMLS_CC); if (share) { if (SUCCESS == php_http_new(&ov, class_entry, (php_http_new_t) php_http_request_datashare_object_new_ex, php_http_request_datashare_class_entry, share, NULL TSRMLS_CC)) { ZVAL_OBJVAL(return_value, ov, 0); @@ -328,48 +326,6 @@ PHP_METHOD(HttpRequestFactory, createDataShare) } end_error_handling(); } -PHP_METHOD(HttpRequestFactory, getGlobalDataShareInstance) -{ - with_error_handling(EH_THROW, php_http_exception_class_entry) { - if (SUCCESS == zend_parse_parameters_none()) { - with_error_handling(EH_THROW, php_http_exception_class_entry) { - zval *instance = *zend_std_get_static_property(php_http_request_datashare_class_entry, ZEND_STRL("instance"), 0, NULL TSRMLS_CC); - - if (Z_TYPE_P(instance) != IS_OBJECT) { - zval *zdriver; - zend_object_value ov; - zend_class_entry *class_entry; - php_http_request_datashare_t *share; - - if (!(class_entry = php_http_request_factory_get_class_entry(getThis(), ZEND_STRL("requestDataShareClass") TSRMLS_CC))) { - class_entry = php_http_request_datashare_class_entry; - } - - if ((zdriver = zend_read_property(php_http_request_factory_class_entry, getThis(), ZEND_STRL("driver"), 0 TSRMLS_CC)) - && (IS_STRING == Z_TYPE_P(zdriver)) - && (share = php_http_request_datashare_global_get(Z_STRVAL_P(zdriver), Z_STRLEN_P(zdriver) TSRMLS_CC)) - && (SUCCESS == php_http_new(&ov, class_entry, (php_http_new_t) php_http_request_datashare_object_new_ex, php_http_request_datashare_class_entry, share, NULL TSRMLS_CC)) - ) { - MAKE_STD_ZVAL(instance); - ZVAL_OBJVAL(instance, ov, 0); - zend_update_static_property(php_http_request_datashare_class_entry, ZEND_STRL("instance"), instance TSRMLS_CC); - - if (PHP_HTTP_G->request_datashare.cookie) { - zend_update_property_bool(php_http_request_datashare_class_entry, instance, ZEND_STRL("cookie"), PHP_HTTP_G->request_datashare.cookie TSRMLS_CC); - } - if (PHP_HTTP_G->request_datashare.dns) { - zend_update_property_bool(php_http_request_datashare_class_entry, instance, ZEND_STRL("dns"), PHP_HTTP_G->request_datashare.dns TSRMLS_CC); - } - } - } - - RETVAL_ZVAL(instance, 1, 0); - } end_error_handling(); - } - } end_error_handling(); -} - - PHP_METHOD(HttpRequestFactory, getDriver) { if (SUCCESS == zend_parse_parameters_none()) { diff --git a/php_http_request_pool.c b/php_http_request_pool.c index 4930122..2cf70ef 100644 --- a/php_http_request_pool.c +++ b/php_http_request_pool.c @@ -57,10 +57,6 @@ PHP_HTTP_API void php_http_request_pool_dtor(php_http_request_pool_t *h) zend_llist_clean(&h->requests.finished); zend_llist_clean(&h->requests.attached); - if (h->persistent_handle_id) { - zval_ptr_dtor(&h->persistent_handle_id); - } - php_http_resource_factory_free(&h->rf); } diff --git a/php_http_request_pool.h b/php_http_request_pool.h index 9984642..d5657a6 100644 --- a/php_http_request_pool.h +++ b/php_http_request_pool.h @@ -55,8 +55,6 @@ struct php_http_request_pool { zend_llist finished; } requests; - zval *persistent_handle_id; - #ifdef ZTS void ***ts; #endif diff --git a/tests/factory.phpt b/tests/factory.phpt index f28eda7..d80bc82 100644 --- a/tests/factory.phpt +++ b/tests/factory.phpt @@ -3,17 +3,17 @@ factory --SKIPIF-- --FILE-- createRequest(); $p = $f->createPool(); $s = $f->createDataShare(); -var_dump(array_map("get_class", array($f,$r,$p,$s))); +var_dump( + array_map("get_class", array($f,$r,$p,$s)), + $f->getDriver() +); + +foreach (array("Request", "Pool", "DataShare") as $type) { + try { + var_dump((new http\Request\Factory(array("driver" => "nonexistant")))->{"create$type"}()); + } catch (Exception $e) { + echo $e->getMessage(), "\n"; + } +} echo "Done\n"; ?> @@ -44,4 +55,8 @@ array(4) { [3]=> string(7) "MyShare" } +string(4) "curl" +requests are not supported by this driver +pools are not supported by this driver +datashares are not supported by this driver Done -- 2.30.2