* start 1.7.0-dev
authorMichael Wallner <mike@php.net>
Fri, 5 Dec 2008 09:37:57 +0000 (09:37 +0000)
committerMichael Wallner <mike@php.net>
Fri, 5 Dec 2008 09:37:57 +0000 (09:37 +0000)
* Implement Request #14408 (Add a customizable timeout for HttpRequestPool::socketSelect)

http_request_pool_api.c
http_requestpool_object.c
package2.xml
php_http.h
php_http_request_pool_api.h

index e5482b4..fcc015e 100644 (file)
@@ -316,6 +316,13 @@ PHP_HTTP_API void _http_request_pool_dtor(http_request_pool *pool)
 
 /* {{{ STATUS http_request_pool_select(http_request_pool *) */
 PHP_HTTP_API STATUS _http_request_pool_select(http_request_pool *pool)
+{
+       return http_request_pool_select_ex(pool, NULL);
+}
+/* }}} */
+
+/* {{{ STATUS http_request_pool_select_ex(http_request_pool *, struct timeval *) */
+PHP_HTTP_API STATUS _http_request_pool_select_ex(http_request_pool *pool, struct timeval *custom_timeout)
 {
        int MAX;
        fd_set R, W, E;
@@ -329,7 +336,11 @@ PHP_HTTP_API STATUS _http_request_pool_select(http_request_pool *pool)
        }
 #endif
        
-       http_request_pool_timeout(pool, &timeout);
+       if (custom_timeout && timerisset(custom_timeout)) {
+               timeout = *custom_timeout;
+       } else {
+               http_request_pool_timeout(pool, &timeout);
+       }
        
        FD_ZERO(&R);
        FD_ZERO(&W);
index 48783c8..03fee88 100644 (file)
@@ -50,7 +50,9 @@ HTTP_END_ARGS;
 
 HTTP_EMPTY_ARGS(send);
 HTTP_EMPTY_ARGS(socketPerform);
-HTTP_EMPTY_ARGS(socketSelect);
+HTTP_BEGIN_ARGS(socketSelect, 0)
+       HTTP_ARG_VAL(timeout, 0)
+HTTP_END_ARGS;
 
 HTTP_EMPTY_ARGS(valid);
 HTTP_EMPTY_ARGS(current);
@@ -277,14 +279,23 @@ PHP_METHOD(HttpRequestPool, socketPerform)
 }
 /* }}} */
 
-/* {{{ proto protected bool HttpRequestPool::socketSelect() */
+/* {{{ proto protected bool HttpRequestPool::socketSelect([double timeout]) */
 PHP_METHOD(HttpRequestPool, socketSelect)
 {
+       double timeout = 0;
+       struct timeval custom_timeout, *custom_timeout_ptr = NULL;
        getObject(http_requestpool_object, obj);
 
-       NO_ARGS;
+       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|d", &timeout)) {
+               RETURN_FALSE;
+       }
+       if (ZEND_NUM_ARGS() && timeout > 0) {
+               custom_timeout.tv_sec = (time_t) timeout;
+               custom_timeout.tv_usec = HTTP_USEC(timeout) % HTTP_MCROSEC;
+               custom_timeout_ptr = &custom_timeout;
+       }
 
-       RETURN_SUCCESS(http_request_pool_select(&obj->pool));
+       RETURN_SUCCESS(http_request_pool_select_ex(&obj->pool, custom_timeout_ptr));
 }
 /* }}} */
 
index e35c328..34d1096 100644 (file)
@@ -30,7 +30,7 @@ support. Parallel requests are available for PHP 5 and greater.
  </lead>
  <date>2008-12-05</date>
  <version>
-  <release>1.6.2</release>
+  <release>1.7.0-dev</release>
   <api>1.6.0</api>
  </version>
  <stability>
@@ -39,11 +39,7 @@ support. Parallel requests are available for PHP 5 and greater.
  </stability>
  <license>BSD, revised</license>
  <notes><![CDATA[
-* Fixed PHP-5.3 API incompatibilities (including bug #15065)
-* Fixed memory corruption with headers and HttpRequest
-* Fixed crash in HttpMessage::unserialize()
-* Fixed bug #14826 (race condition in http_request_dtor)
-* Fixed bug #15223 (http_parse_message cuts off more than headers)
+* Implement Request #14408 (Add a customizable timeout for HttpRequestPool::socketSelect)
 ]]></notes>
  <contents>
   <dir name="/">
index 7495a41..a34457c 100644 (file)
@@ -15,7 +15,7 @@
 #ifndef PHP_EXT_HTTP_H
 #define PHP_EXT_HTTP_H
 
-#define PHP_HTTP_VERSION "1.6.2"
+#define PHP_HTTP_VERSION "1.7.0-dev"
 
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
index c131662..5f86b95 100644 (file)
@@ -73,6 +73,9 @@ PHP_HTTP_API STATUS _http_request_pool_send(http_request_pool *pool);
 #define http_request_pool_select _http_request_pool_select
 PHP_HTTP_API STATUS _http_request_pool_select(http_request_pool *pool);
 
+#define http_request_pool_select_ex _http_request_pool_select_ex
+PHP_HTTP_API STATUS _http_request_pool_select_ex(http_request_pool *pool, struct timeval *custom_timeout);
+
 #define http_request_pool_perform(p) _http_request_pool_perform((p))
 PHP_HTTP_API int _http_request_pool_perform(http_request_pool *pool);