- /* if old_exception is already an HttpRequestPoolException append the new one,
- else create a new HttpRequestPoolException and append the old and new exceptions */
- if (old_exception && Z_OBJCE_P(old_exception) == ce) {
- zval *exprop;
-
- exprop = zend_read_property(ce, old_exception, "exceptionStack", lenof("exceptionStack"), 0 TSRMLS_CC);
- SEP_PROP(&exprop);
- convert_to_array(exprop);
-
- add_next_index_zval(exprop, new_exception);
- zend_update_property(ce, old_exception, "exceptionStack", lenof("exceptionStack"), exprop TSRMLS_CC);
-
- EG(exception) = old_exception;
- } else if (new_exception && Z_OBJCE_P(new_exception) != ce){
- zval *exval, *exprop;
-
- MAKE_STD_ZVAL(exval);
- object_init_ex(exval, ce);
- MAKE_STD_ZVAL(exprop);
- array_init(exprop);
-
- if (old_exception) {
- add_next_index_zval(exprop, old_exception);
+#if HTTP_DEBUG_REQPOOLS
+ {
+ static const char event_strings[][20] = {"TIMEOUT","READ","TIMEOUT|READ","WRITE","TIMEOUT|WRITE","READ|WRITE","TIMEOUT|READ|WRITE","SIGNAL"};
+ fprintf(stderr, "Event on socket %d (%s) event %p of pool %p\n", socket, event_strings[action], ev, pool);
+ }
+#endif
+
+ do {
+#ifdef HAVE_CURL_MULTI_SOCKET_ACTION
+ switch (action & (EV_READ|EV_WRITE)) {
+ case EV_READ:
+ rc = curl_multi_socket_action(pool->ch, socket, CURL_CSELECT_IN, &pool->unfinished);
+ break;
+ case EV_WRITE:
+ rc = curl_multi_socket_action(pool->ch, socket, CURL_CSELECT_OUT, &pool->unfinished);
+ break;
+ case EV_READ|EV_WRITE:
+ rc = curl_multi_socket_action(pool->chm socket, CURL_CSELECT_IN|CURL_CSELECT_OUT, &pool->unfinished);
+ break;
+ default:
+ http_error(HE_WARNING, HTTP_E_SOCKET, "Unknown event %d", (int) action);
+ return;
+ }
+#else
+ rc = curl_multi_socket(pool->ch, socket, &pool->unfinished);
+#endif
+ } while (CURLM_CALL_MULTI_PERFORM == rc);
+
+ /* don't use 'ev' below here, as it might 've been freed in the socket callback */
+
+ if (CURLM_OK != rc) {
+ http_error(HE_WARNING, HTTP_E_SOCKET, curl_multi_strerror(rc));
+ }
+
+ while ((msg = curl_multi_info_read(pool->ch, &remaining))) {
+ if (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_pool_apply_with_arg(pool, _http_request_pool_responsehandler, msg->easy_handle);