From 22616d7660e06425a33ffefe748d4aa6067c2a43 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Wed, 5 Sep 2007 12:15:25 +0000 Subject: [PATCH] - separate http_boundary() - odd fixes for libevent support --- http_api.c | 7 +++++++ http_request_pool_api.c | 24 +++++++++++++----------- http_send_api.c | 2 +- package2.xml | 5 ++--- php_http.h | 2 +- php_http_api.h | 3 +++ 6 files changed, 27 insertions(+), 16 deletions(-) diff --git a/http_api.c b/http_api.c index 61de3e8..aa48e65 100644 --- a/http_api.c +++ b/http_api.c @@ -94,6 +94,13 @@ char *_http_pretty_key(char *key, size_t key_len, zend_bool uctitle, zend_bool x } /* }}} */ +/* {{{ http_boundary(char *, size_t) */ +size_t _http_boundary(char *buf, size_t buf_len TSRMLS_DC) +{ + return snprintf(buf, buf_len, "%lu%0.9f", (ulong) HTTP_G->request.time, (float) php_combined_lcg(TSRMLS_C)); +} +/* }}} */ + /* {{{ void http_error(long, long, char*) */ void _http_error_ex(long type TSRMLS_DC, long code, const char *format, ...) { diff --git a/http_request_pool_api.c b/http_request_pool_api.c index ca18ad0..e67b142 100644 --- a/http_request_pool_api.c +++ b/http_request_pool_api.c @@ -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); @@ -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); diff --git a/http_send_api.c b/http_send_api.c index ae7bc49..cbfe6f0 100644 --- a/http_send_api.c +++ b/http_send_api.c @@ -420,7 +420,7 @@ PHP_HTTP_API STATUS _http_send_ex(const void *data_ptr, size_t data_size, http_s char boundary_str[32], range_header_str[256]; size_t boundary_len, range_header_len; - boundary_len = snprintf(boundary_str, sizeof(boundary_str), "%lu%0.9f", (ulong) HTTP_G->request.time, (float) php_combined_lcg(TSRMLS_C)); + boundary_len = http_boundary(boundary_str, sizeof(boundary_str)); range_header_len = snprintf(range_header_str, sizeof(range_header_str), "Content-Type: multipart/byteranges; boundary=%s", boundary_str); http_send_status_header_ex(206, range_header_str, range_header_len, 1); diff --git a/package2.xml b/package2.xml index 4d85d5d..ef11c52 100644 --- a/package2.xml +++ b/package2.xml @@ -28,9 +28,9 @@ support. Parallel requests are available for PHP 5 and greater. mike@php.net yes - 2007-05-01 + 2007-06-12 - 1.6.0dev + 1.6.0b1 1.6.0 @@ -39,7 +39,6 @@ support. Parallel requests are available for PHP 5 and greater. BSD, revised = 7.16.2 + Added 'retrycount' and 'retrydelay' request options + Added libevent support for libcurl (>= 7.16.0): o added --with-http-curl-libevent configure option diff --git a/php_http.h b/php_http.h index 5dffb53..df9ee95 100644 --- a/php_http.h +++ b/php_http.h @@ -15,7 +15,7 @@ #ifndef PHP_EXT_HTTP_H #define PHP_EXT_HTTP_H -#define PHP_EXT_HTTP_VERSION "1.6.0dev" +#define PHP_EXT_HTTP_VERSION "1.6.0b1" #ifdef HAVE_CONFIG_H # include "config.h" diff --git a/php_http_api.h b/php_http_api.h index b8af494..7163dc1 100644 --- a/php_http_api.h +++ b/php_http_api.h @@ -36,6 +36,9 @@ PHP_HTTP_API long _http_support(long feature); #define pretty_key(key, key_len, uctitle, xhyphen) _http_pretty_key(key, key_len, uctitle, xhyphen) extern char *_http_pretty_key(char *key, size_t key_len, zend_bool uctitle, zend_bool xhyphen); +#define http_boundary(b, l) _http_boundary((b), (l) TSRMLS_CC) +extern size_t _http_boundary(char *buf, size_t len TSRMLS_DC); + #define http_error(type, code, string) _http_error_ex(type, code, "%s", string) #define http_error_ex _http_error_ex extern void _http_error_ex(long type TSRMLS_DC, long code, const char *format, ...); -- 2.30.2