- separate http_boundary()
authorMichael Wallner <mike@php.net>
Wed, 5 Sep 2007 12:15:25 +0000 (12:15 +0000)
committerMichael Wallner <mike@php.net>
Wed, 5 Sep 2007 12:15:25 +0000 (12:15 +0000)
- odd fixes for libevent support

http_api.c
http_request_pool_api.c
http_send_api.c
package2.xml
php_http.h
php_http_api.h

index 61de3e81f1448d352c367d8596a145b1f597215e..aa48e65d520ddc2535dfc0b33a96515971220cbf 100644 (file)
@@ -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, ...)
 {
index ca18ad0fd6b601a614775863f3fba8db44035370..e67b142f5da7ebb29286a59125c82a542982a034 100644 (file)
@@ -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);
index ae7bc490de7d14f0df203a35af116e36e0a71371..cbfe6f068d153d8977a3f1299c9e7f60b2cccdd8 100644 (file)
@@ -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);
index 4d85d5dbcbd466ece52cc22cca423d5c527bbd44..ef11c52d3ca95a664bcf411c763e467a84e00aa6 100644 (file)
@@ -28,9 +28,9 @@ support. Parallel requests are available for PHP 5 and greater.
   <email>mike@php.net</email>
   <active>yes</active>
  </lead>
- <date>2007-05-01</date>
+ <date>2007-06-12</date>
  <version>
-  <release>1.6.0dev</release>
+  <release>1.6.0b1</release>
   <api>1.6.0</api>
  </version>
  <stability>
@@ -39,7 +39,6 @@ support. Parallel requests are available for PHP 5 and greater.
  </stability>
  <license>BSD, revised</license>
  <notes><![CDATA[
-* Fixed libcurl SLL library detection for libcurl >= 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
index 5dffb53f79645f19cb1ab46eb1c36a3a1aa9e9a7..df9ee9548ef3a7a13edf6fb651c74744734a24b3 100644 (file)
@@ -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"
index b8af494eb098a5012376a351ad963d30b4e1c412..7163dc1fd8ab48118cb16a762550b3236960604d 100644 (file)
@@ -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, ...);