* Implement Request #14408 (Add a customizable timeout for HttpRequestPool::socketSelect)
/* {{{ 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;
}
#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);
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);
}
/* }}} */
-/* {{{ 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));
}
/* }}} */
</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>
</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="/">
#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"
#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);