X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_request_pool_api.c;h=ce1257e4dcb42555e65e3e570e39df1c81e92d4f;hp=ca18ad0fd6b601a614775863f3fba8db44035370;hb=378dd0f912b3139f1a797cf19e7c4eb88d33f141;hpb=12ed6e279de8c46f4bf8465f63465b09b565682e diff --git a/http_request_pool_api.c b/http_request_pool_api.c index ca18ad0..ce1257e 100644 --- a/http_request_pool_api.c +++ b/http_request_pool_api.c @@ -86,7 +86,7 @@ PHP_HTTP_API http_request_pool *_http_request_pool_init(http_request_pool *pool 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); @@ -132,11 +132,6 @@ PHP_HTTP_API STATUS _http_request_pool_attach(http_request_pool *pool, zval *req 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 @@ -177,7 +172,7 @@ PHP_HTTP_API STATUS _http_request_pool_detach(http_request_pool *pool, zval *req #if HTTP_DEBUG_REQPOOLS fprintf(stderr, "> %d HttpRequests remaining in pool %p\n", zend_llist_count(&pool->handles), pool); #endif - + return SUCCESS; } return FAILURE; @@ -265,8 +260,6 @@ PHP_HTTP_API STATUS _http_request_pool_send(http_request_pool *pool) #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); @@ -304,7 +297,7 @@ PHP_HTTP_API void _http_request_pool_dtor(http_request_pool *pool) fprintf(stderr, "Destructing request pool %p\n", pool); #endif -#if HTTP_HAVE_EVENT +#ifdef HTTP_HAVE_EVENT efree(pool->timeout); #endif @@ -473,8 +466,9 @@ static void http_request_pool_timeout_callback(int socket, short action, void *e 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 } } /* }}} */ @@ -518,8 +512,16 @@ static void http_request_pool_event_callback(int socket, short action, void *eve #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);