curl multy - infinity loop

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
ddragas
Forum Contributor
Posts: 445
Joined: Sun Apr 18, 2004 4:01 pm

curl multy - infinity loop

Post by ddragas »

can somebody please check why is it entering into infinity loop?
path is array of URL's

infiniti loop is on

Code: Select all

 
        do  {
            curl_multi_exec($mh,$running);
        } 
            while ($running > 0);
 
complete code

Code: Select all

 
        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);  
 

Thank you all

kind regards
User avatar
Chalks
Forum Contributor
Posts: 447
Joined: Thu Jul 12, 2007 7:55 am
Location: Indiana

Re: curl multy - infinity loop

Post by Chalks »

you never change the value of $running when you're inside your while loop.
Post Reply