X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_curl_client_datashare.c;h=1c9cf4d7178964647b94ee7dc0d3b426e889257a;hp=1b47eb56e786163debe707816a8269bbaac3638b;hb=287edcbfb698ff402588f7057dae0bc994d6e8e4;hpb=eebe0f3e8947ecb407451d20aef0611cfcedfdac diff --git a/php_http_curl_client_datashare.c b/php_http_curl_client_datashare.c index 1b47eb5..1c9cf4d 100644 --- a/php_http_curl_client_datashare.c +++ b/php_http_curl_client_datashare.c @@ -67,6 +67,11 @@ static STATUS php_http_curl_client_datashare_attach(php_http_client_datashare_t php_http_curl_client_t *recurl = r->ctx; TSRMLS_FETCH_FROM_CTX(h->ts); + if (r->ops != php_http_curl_client_get_ops()) { + php_http_error(HE_WARNING, PHP_HTTP_E_CLIENT_DATASHARE, "Cannot attach a non-curl client to this datashare"); + return FAILURE; + } + if (CURLE_OK != (rc = curl_easy_setopt(recurl->handle, CURLOPT_SHARE, curl->handle))) { php_http_error(HE_WARNING, PHP_HTTP_E_CLIENT_DATASHARE, "Could not attach request to the datashare: %s", curl_easy_strerror(rc)); return FAILURE; @@ -81,6 +86,11 @@ static STATUS php_http_curl_client_datashare_detach(php_http_client_datashare_t TSRMLS_FETCH_FROM_CTX(h->ts); + if (r->ops != php_http_curl_client_get_ops()) { + php_http_error(HE_WARNING, PHP_HTTP_E_CLIENT_DATASHARE, "Cannot attach a non-curl client to this datashare"); + return FAILURE; + } + if (CURLE_OK != (rc = curl_easy_setopt(recurl->handle, CURLOPT_SHARE, NULL))) { php_http_error(HE_WARNING, PHP_HTTP_E_CLIENT_DATASHARE, "Could not detach request from the datashare: %s", curl_share_strerror(rc)); return FAILURE; @@ -136,11 +146,6 @@ static php_http_resource_factory_ops_t php_http_curlsh_resource_factory_ops = { php_http_curlsh_dtor }; -static zend_class_entry *get_class_entry(void) -{ - return php_http_curl_client_datashare_class_entry; -} - static php_http_client_datashare_ops_t php_http_curl_client_datashare_ops = { &php_http_curlsh_resource_factory_ops, php_http_curl_client_datashare_init, @@ -151,7 +156,7 @@ static php_http_client_datashare_ops_t php_http_curl_client_datashare_ops = { php_http_curl_client_datashare_detach, php_http_curl_client_datashare_setopt, (php_http_new_t) php_http_curl_client_datashare_object_new_ex, - get_class_entry + php_http_curl_client_datashare_get_class_entry }; PHP_HTTP_API php_http_client_datashare_ops_t *php_http_curl_client_datashare_get_ops(void) @@ -163,8 +168,14 @@ PHP_HTTP_API php_http_client_datashare_ops_t *php_http_curl_client_datashare_get #define PHP_HTTP_EMPTY_ARGS(method) PHP_HTTP_EMPTY_ARGS_EX(HttpClientDataShare, method, 0) #define PHP_HTTP_RSHARE_ME(method, visibility) PHP_ME(HttpClientDataShare, method, PHP_HTTP_ARGS(HttpClientDataShare, method), visibility) -zend_class_entry *php_http_curl_client_datashare_class_entry; -zend_function_entry php_http_curl_client_datashare_method_entry[] = { +static zend_class_entry *php_http_curl_client_datashare_class_entry; + +zend_class_entry *php_http_curl_client_datashare_get_class_entry(void) +{ + return php_http_curl_client_datashare_class_entry; +} + +static zend_function_entry php_http_curl_client_datashare_method_entry[] = { EMPTY_FUNCTION_ENTRY }; @@ -180,7 +191,11 @@ zend_object_value php_http_curl_client_datashare_object_new_ex(zend_class_entry o = ecalloc(1, sizeof(*o)); zend_object_std_init((zend_object *) o, ce TSRMLS_CC); +#if PHP_VERSION_ID < 50339 + zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*)); +#else object_properties_init((zend_object *) o, ce); +#endif if (share) { o->share = share;