resolve the 100% CPU curl multi

This commit is contained in:
Gnieark 2016-09-30 18:51:10 +02:00
parent 0fb60e7cf4
commit 759230082c
3 changed files with 8 additions and 20 deletions

View File

@ -1 +1 @@
1660 1662

View File

@ -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

View File

@ -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');
} }