X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_request_datashare.c;h=182ff1add60dbe72fd4292a907a1a25eede83a7b;hp=68e4c073eadefe4e869be5aa702b83af39987314;hb=8d05291f42b3b42159b3fe91492aa4862f3d4405;hpb=df06e2dbf48a3b0d96f2c62071c1b5fc907a98d0 diff --git a/php_http_request_datashare.c b/php_http_request_datashare.c index 68e4c07..182ff1a 100644 --- a/php_http_request_datashare.c +++ b/php_http_request_datashare.c @@ -1,6 +1,18 @@ +/* + +--------------------------------------------------------------------+ + | PECL :: http | + +--------------------------------------------------------------------+ + | Redistribution and use in source and binary forms, with or without | + | modification, are permitted provided that the conditions mentioned | + | in the accompanying LICENSE file are met. | + +--------------------------------------------------------------------+ + | Copyright (c) 2004-2011, Michael Wallner | + +--------------------------------------------------------------------+ +*/ #include "php_http.h" +#include #include #include @@ -28,7 +40,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 +52,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 +67,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 +99,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 +164,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 +229,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 +249,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 +292,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 +357,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; @@ -385,3 +402,13 @@ PHP_RSHUTDOWN_FUNCTION(http_request_datashare) return SUCCESS; } + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ +