Bug #60790 [Fbk->NoF]: "curl_multi_select" executed first time always one second
| From: | php-bugs at lists dot php dot net | Date: | Mon, 18 Feb 2013 00:35:38 +0000 |
| Subject: | Bug #60790 [Fbk->NoF]: "curl_multi_select" executed first time always one second | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-177060@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60790&edit=1
ID: 60790
Updated by: php-bugs@lists.php.net
Reported by: leonchuk at gmail dot com
Summary: "curl_multi_select" executed first time always one
second
-Status: Feedback
+Status: No Feedback
Type: Bug
Package: cURL related
Operating System: windows (XP,7)
PHP Version: 5.3.9
Assigned To: pierrick
New Comment:
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
Previous Comments:
------------------------------------------------------------------------
[2012-12-13 20:17:25] leonchuk at gmail dot com
Thanks pierrick, marfil for answers.
But, your codes still dont work:(
I found the answer by putting the following code:
...
while ($mrc == CURLM_CALL_MULTI_PERFORM);
#fix
if(strtoupper(substr(PHP_OS,0,3)) === 'WIN'){
curl_multi_select($this->m_handle, 0.005);
curl_multi_exec($this->m_handle, $active);
}
...
------------------------------------------------------------------------
[2012-12-13 16:43:05] cristian dot marfil at gmail dot com
Works for me!
// jlcooke - thanks to http://technosophos.com/content/connection-sharing-curl-
php-how-re-use-http-connections-knock-70-rest-network-time
// https://forums.aws.amazon.com/thread.jspa?messageID=397448
class RequestCore {
public static $curl_multi_handle = null;
public static function curlExecUsingMulti($curl_handle) {
set_time_limit(1); //Test
// Create a multi if necessary.
if (empty(RequestCore::$curl_multi_handle)) {
RequestCore::$curl_multi_handle = curl_multi_init();
}
// Add the handle to be processed.
curl_multi_add_handle(RequestCore::$curl_multi_handle, $curl_handle);
// Do all the processing.
$active = NULL;
do {
$ret = curl_multi_exec(RequestCore::$curl_multi_handle, $active);
} while ($ret == CURLM_CALL_MULTI_PERFORM);
while ($active && $ret == CURLM_OK) {
//FIX https://bugs.php.net/bug.php?id=60790&edit=1
by
pierrick@php.net
if (curl_multi_select(RequestCore::$curl_multi_handle)
== -1) {
usleep(100);
}
//if (curl_multi_select(RequestCore::$curl_multi_handle) != -1) {
do {
$mrc =
curl_multi_exec(RequestCore::$curl_multi_handle, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
//}
}
// Remove the handle from the multi processor.
curl_multi_remove_handle(RequestCore::$curl_multi_handle, $curl_handle);
return curl_multi_getcontent($curl_handle);
}
}
------------------------------------------------------------------------
[2012-09-22 13:34:53] pierrick@php.net
This behavior is probably related to Bug #61141. Can you try this script
$ch1 = curl_init();
curl_setopt_array($ch1, array(CURLOPT_URL=>"http://lxr.php.net/",
CURLOPT_HEADER=>0, CURLOPT_RETURNTRANSFER=>1));
$mh = curl_multi_init();
curl_multi_add_handle($mh,$ch1);
$active = null;
do $mrc = curl_multi_exec($mh, $active);
while ($mrc == CURLM_CALL_MULTI_PERFORM);
$start_time = microtime(true);
while ($active && $mrc == CURLM_OK) {
if (curl_multi_select($mh) == -1) {
usleep(100);
}
do $mrc = curl_multi_exec($mh, $active);
while ($mrc == CURLM_CALL_MULTI_PERFORM);
}
curl_multi_remove_handle($mh, $ch1); curl_multi_close($mh);
And let me know if you still have your problem ?
------------------------------------------------------------------------
[2012-04-03 16:27:11] bompus at gmail dot com
Possibly related to 61141 and 61240
------------------------------------------------------------------------
[2012-03-24 07:28:59] qiwei dot mo at gmail dot com
I have the same problem white them.
Env: win7 + php5.4.0
Use the code as curl_multi-exec
http://cn2.php.net/manual/zh/function.curl-multi-exec.php
cause the final error: Fatal error: Maximum execution time of 30 seconds
exceeded. But it be runing well in php5.3.6
In PHP5.4 , when i replace the under code
-----------------------------------
$active = null;
// æ§è¡æ¹å¤ç奿
do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
while ($active && $mrc == CURLM_OK) {
if (curl_multi_select($mh) != -1) {
do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
}
}
--------------------------------------
With
do {
curl_multi_exec($hMultiCurl, $iRunning);
} while ($iRunning > 0);
-------------------------------------
the programe run ok
So the question is the curl_multi_select bug , cause the while infinite loop.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=60790
--
Edit this bug report at https://bugs.php.net/bug.php?id=60790&edit=1