#47475 [NEW]: Propose to add curl_multi_timeout() to curl_multi_select(..., 0)

From: Date: Sun, 22 Feb 2009 16:12:19 +0000
Subject: #47475 [NEW]: Propose to add curl_multi_timeout() to curl_multi_select(..., 0)
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-134089@lists.php.net to get a copy of this message
From: php at koterov dot ru Operating system: all PHP version: 5.2.9RC3 PHP Bug Type: cURL related Bug description: Propose to add curl_multi_timeout() to curl_multi_select(..., 0) Description: ------------ I propose to add the following simple modification to curl_multi_select() function. Now it is greatly miss the functionality to detect the timeout automatically. ext\curl\multi.c: ... PHP_FUNCTION(curl_multi_select) { zval *z_mh; php_curlm *mh; fd_set readfds; fd_set writefds; fd_set exceptfds; int maxfd; double timeout = 1.0; struct timeval to; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|d", &z_mh, &timeout) == FAILURE) { return; } ZEND_FETCH_RESOURCE(mh, php_curlm *, &z_mh, -1, le_curl_multi_handle_name, le_curl_multi_handle); _make_timeval_struct(&to, timeout); + + /* If timeout == 0 is passed, detect it automatically. */ + if (!to.tv_sec && !to.tv_usec) { + long max_tout = 1000; + if ((CURLM_OK == curl_multi_timeout(mh->multi, &max_tout)) && (max_tout != -1)) { + to->tv_sec = max_tout / 1000; + to->tv_usec = (max_tout % 1000) * 1000; + } + } + FD_ZERO(&readfds); FD_ZERO(&writefds); FD_ZERO(&exceptfds); curl_multi_fdset(mh->multi, &readfds, &writefds, &exceptfds, &maxfd); RETURN_LONG(select(maxfd + 1, &readfds, &writefds, &exceptfds, &to)); } Reproduce code: --------------- cURL has built-in ability to detect the minimal delay till a next handle timeout in the pool. But there is no chance to use this feature in PHP, because there is no such function. So we have to perform busy wait loops. Expected result: ---------------- curl_multi_select($h, 0) waits till the next request timeout at most. Actual result: -------------- there is no chance to catch a handle timeout without busy-wait loop now. -- Edit bug report at http://bugs.php.net/?id=47475&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47475&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47475&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47475&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=47475&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47475&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=47475&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=47475&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=47475&r=needscript Try newer version: http://bugs.php.net/fix.php?id=47475&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=47475&r=support Expected behavior: http://bugs.php.net/fix.php?id=47475&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=47475&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=47475&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=47475&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47475&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=47475&r=dst IIS Stability: http://bugs.php.net/fix.php?id=47475&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=47475&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=47475&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=47475&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=47475&r=mysqlcfg

« previous php.bugs (#134089) next »