- request pools for ZE2 only yet
[m6w6/ext-http] / http_request_api.c
index 87d40a01e49e1d47f8c6c335c66a7c25af204c39..722e0b5a3ddd8b7e46d8eaeac0aed20deb757cb6 100644 (file)
@@ -177,7 +177,7 @@ void *_http_request_data_copy(int type, void *data TSRMLS_DC)
                        zend_llist_add_element(&HTTP_G(request).copies.contexts, &data);
                        return data;
                }
-               
+
                default:
                {
                        return data;
@@ -819,7 +819,7 @@ PHP_HTTP_API STATUS _http_request_method_unregister(unsigned long method TSRMLS_
 }
 /* }}} */
 
-
+#ifdef ZEND_ENGINE_2
 /* {{{ http_request_pool *http_request_pool_init(http_request_pool *) */
 PHP_HTTP_API http_request_pool *_http_request_pool_init(http_request_pool *pool TSRMLS_DC)
 {
@@ -868,14 +868,17 @@ PHP_HTTP_API STATUS _http_request_pool_attach(http_request_pool *pool, zval *req
 
                if (SUCCESS != http_request_object_requesthandler(req, request, body)) {
                        http_error_ex(E_WARNING, HTTP_E_CURL, "Could not initialize HttpRequest object for attaching to the HttpRequestPool");
-               } else if (CURLM_OK != (code = curl_multi_add_handle(pool->ch, req->ch))) {
-                       http_error_ex(E_WARNING, HTTP_E_CURL, "Could not attach HttpRequest object to the HttpRequestPool: %s", curl_multi_strerror(code));
                } else {
-                       req->pool = pool;
-                       zval_add_ref(&request);
-                       zend_llist_add_element(&pool->handles, &request);
-                       zend_llist_add_element(&pool->bodies, &body);
-                       return SUCCESS;
+                       code = curl_multi_add_handle(pool->ch, req->ch);
+                       if ((CURLM_OK != code) && (CURLM_CALL_MULTI_PERFORM != code)) {
+                               http_error_ex(E_WARNING, HTTP_E_CURL, "Could not attach HttpRequest object to the HttpRequestPool: %s", curl_multi_strerror(code));
+                       } else {
+                               req->pool = pool;
+                               zval_add_ref(&request);
+                               zend_llist_add_element(&pool->handles, &request);
+                               zend_llist_add_element(&pool->bodies, &body);
+                               return SUCCESS;
+                       }
                }
                efree(body);
        }
@@ -1007,6 +1010,7 @@ static void http_request_pool_freehandle(zval **request, http_request_pool *pool
 #endif
 }
 /* }}} */
+#endif /* ZEND_ENGINE_2 */
 
 /* {{{ char *http_request_methods[] */
 static const char *const http_request_methods[] = {