ensure we're talking to curl ops
authorMichael Wallner <mike@php.net>
Mon, 30 Jul 2012 18:29:59 +0000 (18:29 +0000)
committerMichael Wallner <mike@php.net>
Mon, 30 Jul 2012 18:29:59 +0000 (18:29 +0000)
php_http_curl_client_pool.c

index 21d33144c6ae8abd78b57229495916bb0ba396cc..d1873fb5b754e6ad717114c0ec31987c3db974ae 100644 (file)
@@ -281,6 +281,11 @@ static STATUS php_http_curl_client_pool_attach(php_http_client_pool_t *h, php_ht
        CURLMcode rs;
        TSRMLS_FETCH_FROM_CTX(h->ts);
 
+       if (r->ops != php_http_curl_client_get_ops()) {
+               php_http_error(HE_WARNING, PHP_HTTP_E_CLIENT_POOL, "Cannot attach a non-curl client to this pool");
+               return FAILURE;
+       }
+
        if (SUCCESS != php_http_curl_client_prepare(r, m)) {
                return FAILURE;
        }
@@ -298,10 +303,15 @@ static STATUS php_http_curl_client_pool_detach(php_http_client_pool_t *h, php_ht
 {
        php_http_curl_client_pool_t *curl = h->ctx;
        php_http_curl_client_t *recurl = r->ctx;
-       CURLMcode rs = curl_multi_remove_handle(curl->handle, recurl->handle);
+       CURLMcode rs;
        TSRMLS_FETCH_FROM_CTX(h->ts);
 
-       if (CURLM_OK == rs) {
+       if (r->ops != php_http_curl_client_get_ops()) {
+               php_http_error(HE_WARNING, PHP_HTTP_E_CLIENT_POOL, "Cannot attach a non-curl client to this pool");
+               return FAILURE;
+       }
+
+       if (CURLM_OK == (rs = curl_multi_remove_handle(curl->handle, recurl->handle))) {
                return SUCCESS;
        } else {
                php_http_error(HE_WARNING, PHP_HTTP_E_CLIENT_POOL, "Could not detach request from pool: %s", curl_multi_strerror(rs));