* 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 e5482b41da4778dc90661b82b11f59c01fd3f262..fcc015ea8692dca4486d64134f22c40ab058d8fa 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 48783c8d3c9f52158fb97f76c88a7a8d4f588131..03fee88c575ca09a40ea5726d71cc3ffefd93d5e 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 e35c3280523930877c9c7d2fa6f30442187500f7..34d1096c0d405b032e6555ff2f699472a4fb63ee 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 7495a416fbe760aa723372243ef3abf847a018ad..a34457c125e24c8495e32323b3d9d53136704482 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 c1316622fc4b52f54fcbd325cd7352c69caece8d..5f86b958123584c8f4cbb1699832025a8797a75d 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);