#include "php_http.h"
+#include <curl/curl.h>
#include <ext/standard/php_string.h>
#include <ext/spl/spl_iterators.h>
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);
}
}
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);
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))) {
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)
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);
}
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) {
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);
}
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();
}