X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=php_http_request_datashare.c;h=d6cbaa7e1c13568deb52a2fdb00e52adce24f65e;hb=4743c5114bcdcf8d478e140beb63fecfeccd01a4;hp=68e4c073eadefe4e869be5aa702b83af39987314;hpb=df06e2dbf48a3b0d96f2c62071c1b5fc907a98d0;p=m6w6%2Fext-http diff --git a/php_http_request_datashare.c b/php_http_request_datashare.c index 68e4c07..d6cbaa7 100644 --- a/php_http_request_datashare.c +++ b/php_http_request_datashare.c @@ -1,6 +1,7 @@ #include "php_http.h" +#include #include #include @@ -28,7 +29,7 @@ php_http_request_datashare_t *php_http_request_datashare_global_get(const char * 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, 1 TSRMLS_CC); + 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); } } @@ -40,9 +41,9 @@ php_http_request_datashare_t *php_http_request_datashare_global_get(const char * 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, 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, zend_bool persistent TSRMLS_DC) { - php_http_request_datashare_t *free_h; + php_http_request_datashare_t *free_h = NULL; if (!h) { free_h = h = pemalloc(sizeof(*h), persistent); @@ -55,6 +56,7 @@ PHP_HTTP_API php_http_request_datashare_t *php_http_request_datashare_init(php_h TSRMLS_SET_CTX(h->ts); } h->ops = ops; + h->rf = rf ? rf : php_http_resource_factory_init(NULL, h->ops->rsrc, NULL, NULL); if (h->ops->init) { if (!(h = h->ops->init(h, init_arg))) { @@ -86,6 +88,10 @@ PHP_HTTP_API void php_http_request_datashare_dtor(php_http_request_datashare_t * pefree(h->requests, h->persistent); h->requests = NULL; } + + if (h->persistent_handle_id) { + zval_ptr_dtor(&h->persistent_handle_id); + } } PHP_HTTP_API void php_http_request_datashare_free(php_http_request_datashare_t **h) @@ -147,11 +153,11 @@ static void detach(void *r, void *h TSRMLS_DC) PHP_HTTP_API void php_http_request_datashare_reset(php_http_request_datashare_t *h) { + TSRMLS_FETCH_FROM_CTX(h->ts); + if (h->ops->reset) { h->ops->reset(h); } else if (h->ops->detach) { - TSRMLS_FETCH_FROM_CTX(h->ts); - zend_llist_apply_with_argument(PHP_HTTP_REQUEST_DATASHARE_REQUESTS(h), detach, h TSRMLS_CC); } @@ -212,7 +218,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, 0 TSRMLS_CC); + o->share = php_http_request_datashare_init(NULL, NULL, NULL, NULL, 0 TSRMLS_CC); } if (ptr) { @@ -232,7 +238,7 @@ void php_http_request_datashare_object_free(void *object TSRMLS_DC) if (!o->share->persistent) { php_http_request_datashare_free(&o->share); } - zend_object_std_dtor((zend_object *) o); + zend_object_std_dtor((zend_object *) o TSRMLS_CC); efree(o); } @@ -275,7 +281,7 @@ static zval **php_http_request_datashare_object_get_prop_ptr(zval *object, zval PHP_METHOD(HttpRequestDataShare, __construct) { - with_error_handling(EH_THROW, PHP_HTTP_EX_CE(runtime)) { + with_error_handling(EH_THROW, php_http_exception_class_entry) { zend_parse_parameters_none(); } end_error_handling(); } @@ -340,7 +346,7 @@ PHP_METHOD(HttpRequestDataShare, reset) PHP_MINIT_FUNCTION(http_request_datashare) { - PHP_HTTP_REGISTER_CLASS(http\\request, DataShare, http_request_datashare, php_http_object_class_entry, 0); + PHP_HTTP_REGISTER_CLASS(http\\Request, DataShare, http_request_datashare, php_http_object_class_entry, 0); php_http_request_datashare_class_entry->create_object = php_http_request_datashare_object_new; memcpy(&php_http_request_datashare_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); php_http_request_datashare_object_handlers.clone_obj = NULL;