TSRMLS_SET_CTX(pool->tsrm_ls);
-#if HTTP_HAVE_EVENT
+#ifdef HTTP_HAVE_EVENT
pool->timeout = ecalloc(1, sizeof(struct event));
curl_multi_setopt(pool->ch, CURLMOPT_SOCKETDATA, pool);
curl_multi_setopt(pool->ch, CURLMOPT_SOCKETFUNCTION, http_request_pool_socket_callback);
zend_llist_add_element(&pool->handles, &request);
++pool->unfinished;
-#ifdef HTTP_HAVE_EVENT
- if (pool->runsocket) {
- while (CURLM_CALL_MULTI_PERFORM == curl_multi_socket_all(pool->ch, &pool->unfinished));
- }
-#endif
#if HTTP_DEBUG_REQPOOLS
fprintf(stderr, "> %d HttpRequests attached to pool %p\n", zend_llist_count(&pool->handles), pool);
#endif
#if HTTP_DEBUG_REQPOOLS
fprintf(stderr, "> %d HttpRequests remaining in pool %p\n", zend_llist_count(&pool->handles), pool);
#endif
-
+
return SUCCESS;
}
return FAILURE;
#ifdef HTTP_HAVE_EVENT
if (pool->useevents) {
- /* run socket action */
- pool->runsocket = 1;
do {
while (CURLM_CALL_MULTI_PERFORM == curl_multi_socket_all(pool->ch, &pool->unfinished));
event_base_dispatch(HTTP_G->request.pool.event.base);
fprintf(stderr, "Destructing request pool %p\n", pool);
#endif
-#if HTTP_HAVE_EVENT
+#ifdef HTTP_HAVE_EVENT
efree(pool->timeout);
#endif
msg = curl_multi_info_read(pool->ch, &remaining);
if (msg && CURLMSG_DONE == msg->msg) {
if (CURLE_OK != msg->data.result) {
- http_request *r = NULL;
- curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, &r);
- http_error_ex(HE_WARNING, HTTP_E_REQUEST, "%s; %s (%s)", curl_easy_strerror(msg->data.result), r?r->_error:"", r?r->url:"");
+ http_request_storage *st = http_request_storage_get(msg->easy_handle);
+ http_error_ex(HE_WARNING, HTTP_E_REQUEST, "%s; %s (%s)", curl_easy_strerror(msg->data.result), st?st->errorbuffer:"", st?st->url:"");
}
http_request_pool_apply_with_arg(pool, _http_request_pool_apply_responsehandler, msg->easy_handle);
}
if (CURLM_OK != rc) {
http_error(HE_WARNING, HTTP_E_SOCKET, curl_multi_strerror(rc));
}
-
+#if 0
http_request_pool_timer_callback(pool->ch, 1000, pool);
+#endif
}
}
/* }}} */
#endif
} while (CURLM_CALL_MULTI_PERFORM == rc);
- if (CURLM_OK != rc) {
- http_error(HE_WARNING, HTTP_E_SOCKET, curl_multi_strerror(rc));
+ switch (rc) {
+ case CURLM_BAD_SOCKET:
+#if 0
+ fprintf(stderr, "!!! Bad socket: %d (%d)\n", socket, (int) action);
+#endif
+ case CURLM_OK:
+ break;
+ default:
+ http_error(HE_WARNING, HTTP_E_SOCKET, curl_multi_strerror(rc));
+ break;
}
http_request_pool_responsehandler(pool);