|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42300 curl_copy_handle use curl_multi_exec get nothing.
Submitted: 2007-08-14 18:57 UTC Modified: 2007-11-24 01:00 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: foxgoblin at gmail dot com Assigned:
Status: No Feedback Package: cURL related
PHP Version: 5CVS-2007-08-14 (snap) OS: windows xp
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.
Block user comment
Status: Assign to:
Bug Type:
From: foxgoblin at gmail dot com
New email:
PHP Version: OS:


 [2007-08-14 18:57 UTC] foxgoblin at gmail dot com
use curl_copy_handle copy the curl handle, add in curl multi handle, curl_multi_exec return nothing.

Reproduce code:
function getMultiCUrlContent($chs){
	$contents = array();
	$mh = curl_multi_init();
	foreach($chs as $key => $ch){
	do {
	  $mrc = curl_multi_exec($mh, $active);
	} while ($mrc == CURLM_CALL_MULTI_PERFORM);
	while ($active and $mrc == CURLM_OK) {
	  // wait for network
	  if (curl_multi_select($mh) != -1) {
	   // pull in any new data, or at least handle timeouts
	   do {
	     $mrc = curl_multi_exec($mh, $active);
	   } while ($mrc == CURLM_CALL_MULTI_PERFORM);
	if ($mrc != CURLM_OK) {
	  echo "[".date("Y-m-d H:i:s")."]\t[getMultiCUrlContent error]\t".$mrc."\n";
	foreach($chs as $key => $ch){
		if(curl_errno($ch) == CURLE_OK){
			$contents[$key]= curl_multi_getcontent($ch);
			echo "[".date("Y-m-d H:i:s")."]\t[get content error]\t".curl_error($ch)."\n";
	return $contents;

$chs = array();
$ch = curl_init("");
$chs[] = $ch;
$ch = curl_copy_handle($ch);
$chs[] = $ch;
$contents = getMultiCUrlContent($chs);

Expected result:
    [0] => <html><head><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><title>Google</title>...
    [1] => <html><head><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><title>Google</title>...

Actual result:
    [0] => <html><head><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><title>Google</title>...
    [1] => 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-13 13:19 UTC]
Your code works just fine for me with PHP 5.3-dev and libcurl 7.17.0.  Which version of libcurl are you using?  Does upgrading the a more recent version help?
 [2007-10-18 17:33 UTC] foxgoblin at gmail dot com
cURL Information => libcurl/7.16.0 OpenSSL/0.9.8e zlib/1.2.3

I use distribute Windows Binaries php-5.2.4, it build php_curl extension with libcurl/7.16.0 .
 [2007-10-18 17:38 UTC] foxgoblin at gmail dot com
I try php/5.2.0 , it's ok!

it build php_curl with libcurl/7.14.0

cURL Information => libcurl/7.14.0 OpenSSL/0.9.8d zlib/1.2.3
 [2007-11-24 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-2023 The PHP Group
All rights reserved.
Last updated: Fri Jun 09 11:03:41 2023 UTC