fix curl_multi with libevent2
[m6w6/ext-http] / php_http_curl_client_datashare.c
index cc370bad0f2817ed639a6eb89288d4196384bbcc..1c9cf4d7178964647b94ee7dc0d3b426e889257a 100644 (file)
@@ -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;
@@ -181,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;