Skip to content

Instantly share code, notes, and snippets.

@vanhoavn
Created January 15, 2017 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vanhoavn/e426ffdfc3f1502084c56d9190bf5a83 to your computer and use it in GitHub Desktop.
Save vanhoavn/e426ffdfc3f1502084c56d9190bf5a83 to your computer and use it in GitHub Desktop.
<?php
// ....
function processCurlMulti($curl_session_multi) {
do {
$mrc = curl_multi_exec($curl_session_multi, $n_running_channel);
} while ($mrc == CURLM_CALL_MULTI_PERFORM || $n_running_channel > 0);
$n_idle = 0;
while ($mrc == CURLM_OK && $n_idle <= MAX_WAIT_CYCLES) {
if (curl_multi_select($curl_session_multi) != -1) {
$n_idle = 0;
do {
$mrc = curl_multi_exec($curl_session_multi, $n_running_channel);
} while ($mrc == CURLM_CALL_MULTI_PERFORM || $n_running_channel > 0);
} else {
$n_idle++;
usleep(250000);
}
}
return $mrc;
}
// ....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment