strange comporting of CURL library
Posted: Thu Sep 18, 2008 5:56 pm
Hi all
I've got strange comporting of CURL library.
I've got 2 servers witch are hosting 2 sites.
If I "fire" (with curl script below) from first server, php script that is on second server it "fires" back php script on first server, and that is ok and ment to be like this.
problem is that it goes in endless loop. It will never stop.
And If I run this script in browser it runs only once (like it should)
Is it something wrong with my CURL script below?
I've got strange comporting of CURL library.
I've got 2 servers witch are hosting 2 sites.
If I "fire" (with curl script below) from first server, php script that is on second server it "fires" back php script on first server, and that is ok and ment to be like this.
problem is that it goes in endless loop. It will never stop.
And If I run this script in browser it runs only once (like it should)
Is it something wrong with my CURL script below?
Code: Select all
$path = array('first/path/to/thefile/', 'second/path/to/thefile/', ......);
for($r = 0; $r<= count($path); $r++)
{
$ch[] = $r;
}
for($chInit = 0; $chInit<count($ch); $chInit++)
{
$ch[$chInit] = curl_init();
curl_setopt($ch[$chInit], CURLOPT_URL, $path[$chInit]);
}
$mh = curl_multi_init();
for($chMH = 0; $chMH<count($ch); $chMH++)
{
curl_multi_add_handle($mh,$ch[$chMH]);
}
$running=null;
do {
curl_multi_exec($mh,$running);
}
while ($running > 0);
for($chMH1 = 0; $chMH1<count($ch); $chMH1++)
{
curl_multi_remove_handle($mh,$ch[$chMH1]);
}
curl_multi_close($mh);