resolve the 100% CPU curl multi

pull/96/head
Gnieark 8 years ago
parent 0fb60e7cf4
commit 759230082c

@ -1 +1 @@
1660 1662

@ -181,22 +181,13 @@ class TronGame
); );
curl_multi_add_handle($cmh,$ch[$i]); curl_multi_add_handle($cmh,$ch[$i]);
} }
//send the requests //send the requests
do { do {
$returnVal = curl_multi_exec($cmh, $runningHandles); $returnVal = curl_multi_exec($cmh, $runningHandles);
} while ($returnVal == CURLM_CALL_MULTI_PERFORM); }while($runningHandles > 0);
// Loop and continue processing the request
while ($runningHandles && $returnVal== CURLM_OK) {
// Wait forever for network
$numberReady = curl_multi_select($cmh);
if ($numberReady != -1) {
// Pull in any new data, or at least handle timeouts
do {
$returnVal = curl_multi_exec($cmh, $runningHandles);
} while ($returnVal == CURLM_CALL_MULTI_PERFORM);
}
}
//Get results //Get results
for ($i = 0; $i < count($iasUrls); $i++){ for ($i = 0; $i < count($iasUrls); $i++){
// Check for errors // Check for errors

@ -105,13 +105,10 @@ function play(gameId,xd_check){
drawMap(reponse['lap']); drawMap(reponse['lap']);
if(reponse['continue'] == '1'){ if(reponse['continue'] == '1'){
setTimeout(function(){ //setTimeout(function(){
play(gameId,xd_check); play(gameId,xd_check);
} ,500); //} ,500);
}else{ }else{
alert ('game ended'); alert ('game ended');
} }

Loading…
Cancel
Save