php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42020 curl_multi_select causes php to fail, silently
Submitted: 2007-07-17 18:47 UTC Modified: 2007-07-26 01:00 UTC
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: adz999 at yahoo dot co dot uk Assigned:
Status: No Feedback Package: cURL related
PHP Version: 5.2.3 OS: Free BSD (i386)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: adz999 at yahoo dot co dot uk
New email:
PHP Version: OS:

 

 [2007-07-17 18:47 UTC] adz999 at yahoo dot co dot uk
Description:
------------
I am using (a slight variation of) the user-contributed example on this page:http://uk2.php.net/manual/en/function.curl-multi-exec.php.

Sometimes it works and sometimes it causes php to fail, without displaying any error notice (error reporting set to E_WARNING).  I cannot work out what it is that causes it to fail or not fail, but if I run the same requests on the script multiple times it behaves the same every time.

By getting php to print a message between each line of code I have narrowed the problem down to this line:
if (curl_multi_select($mh) != -1)

This is the php info for the server:
http://phpinfo.hostultra.com/

The problem does NOT occur when the script is executed on my local testing server (Mac OS X 10.4.8, PHP 5.2.1).



Reproduce code:
---------------
<?php
$mh = curl_multi_init();
foreach(array_keys($arr_requests) as $i)
		curl_multi_add_handle ($mh,$arr_requests[$i]); //each element of $arr_requests is a curl handle

print "got as far as executing the curl stuff<br>"; while (@ob_end_flush()); while (@flush());

do		{
		$mrc = curl_multi_exec($mh, $active);
		} while ($mrc == CURLM_CALL_MULTI_PERFORM && $active>0 && microtime(1)<$time);


print "1<br>"; while (@ob_end_flush()); while (@flush());

while ($active>0 and $mrc == CURLM_OK && microtime(1)<$time){
		print "2<br>"; while (@ob_end_flush()); while (@flush()); //this gets printed out fine
		// wait for network
		if (curl_multi_select($mh) != -1){
				// pull in any new data, or at least handle timeouts
    			do		{
						print "3<br>"; while (@ob_end_flush()); while (@flush()); //php never gets this far
						$mrc = curl_multi_exec($mh, $active);
						} while ($mrc == CURLM_CALL_MULTI_PERFORM && $active>0 && microtime(1)<$time);
				}
		}//end while

Expected result:
----------------
If curl_multi_select($mh) was equal to -1 then I would expect the while loop
while ($active>0 and $mrc == CURLM_OK && microtime(1)<$time)

Actual result:
--------------
PHP outputs:
got as far as executing the curl stuff
1
2

...and then it stops.  The connection to the browser is no longer active.  That's it, it just stops there and does no more.  No error message.


Even if I change the line
if (curl_multi_select($mh) != -1)
to just
if (curl_multi_select($mh))

the result is exactly the same

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-17 18:58 UTC] adz999 at yahoo dot co dot uk
Some of my submission did not post properly:

The "Reproduce code" section should have this at the end:
print "4<br>";

The "Expected result" section should continue:
...to loop around again, and therefore print out "2<br" again.
Or if curl_multi_select($mh) was NOT equal to -1 then I would expect php to print out "3<br>" regardless of whether it then went on to execute curl_multi_exec.
 [2007-07-18 13:02 UTC] adz999 at yahoo dot co dot uk
Apologies for my ignorance, and noob-ness but I downloaded the cvs snapshot and I have no idea what to do with it!!  The bug only occurs on my webhost's server (BSD on i386) and not on my own server (OS X) despite having the same php version.
 [2007-07-18 13:03 UTC] adz999 at yahoo dot co dot uk
...and so I can't install the latest version anyway (on the webhost).
 [2007-07-18 23:19 UTC] jani@php.net
Ask the webhoster to test it for you?
 [2007-07-26 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Sep 26 00:01:24 2020 UTC