mirror of
https://github.com/Yubico/yubikey-val.git
synced 2025-01-20 10:52:15 +01:00
Remove now unused retrieveURLasync_old()
This commit is contained in:
parent
765620f17b
commit
b8d18af10c
@ -521,85 +521,6 @@ class SyncLib
|
||||
return retrieveURLasync("YK-VAL sync", $urls, $this->myLog, $ans_req, $match="status=OK", $returl=True, $timeout);
|
||||
}
|
||||
|
||||
/*
|
||||
This function takes a list of URLs. It will return the content of
|
||||
the first successfully retrieved URL, whose content matches ^OK.
|
||||
The request are sent asynchronously. Some of the URLs can fail
|
||||
with unknown host, connection errors, or network timeout, but as
|
||||
long as one of the URLs given work, data will be returned. If all
|
||||
URLs fail, data from some URL that did not match parameter $match
|
||||
(defaults to ^OK) is returned, or if all URLs failed, false.
|
||||
*/
|
||||
function retrieveURLasync_old ($urls, $ans_req=1, $timeout=1.0) {
|
||||
$mh = curl_multi_init();
|
||||
|
||||
$ch = array();
|
||||
foreach ($urls as $id => $url) {
|
||||
$this->log(LOG_DEBUG, "url in retrieveURLasync is " . $url);
|
||||
$handle = curl_init();
|
||||
|
||||
curl_setopt($handle, CURLOPT_URL, $url);
|
||||
curl_setopt($handle, CURLOPT_USERAGENT, "YK-VAL");
|
||||
curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($handle, CURLOPT_FAILONERROR, true);
|
||||
curl_setopt($handle, CURLOPT_TIMEOUT, $timeout);
|
||||
|
||||
curl_multi_add_handle($mh, $handle);
|
||||
|
||||
$ch[$handle] = $handle;
|
||||
}
|
||||
|
||||
$str = false;
|
||||
$ans_count = 0;
|
||||
$ans_arr = array();
|
||||
|
||||
do {
|
||||
while (($mrc = curl_multi_exec($mh, $active)) == CURLM_CALL_MULTI_PERFORM)
|
||||
;
|
||||
|
||||
while ($info = curl_multi_info_read($mh)) {
|
||||
debug ("YK-KSM multi", $info);
|
||||
if ($info['result'] == CURLE_OK) {
|
||||
$str = curl_multi_getcontent($info['handle']);
|
||||
if (preg_match("/status=OK/", $str)) {
|
||||
$error = curl_error ($info['handle']);
|
||||
$errno = curl_errno ($info['handle']);
|
||||
$cinfo = curl_getinfo ($info['handle']);
|
||||
debug("YK-KSM errno/error: " . $errno . "/" . $error, $cinfo);
|
||||
$ans_count++;
|
||||
$ans_arr[]="url=" . $cinfo['url'] . "\n" . $str;
|
||||
}
|
||||
|
||||
if ($ans_count >= $ans_req) {
|
||||
foreach ($ch as $h) {
|
||||
curl_multi_remove_handle ($mh, $h);
|
||||
curl_close ($h);
|
||||
}
|
||||
curl_multi_close ($mh);
|
||||
|
||||
return $ans_arr;
|
||||
}
|
||||
|
||||
curl_multi_remove_handle ($mh, $info['handle']);
|
||||
curl_close ($info['handle']);
|
||||
unset ($ch[$info['handle']]);
|
||||
}
|
||||
|
||||
curl_multi_select ($mh);
|
||||
}
|
||||
} while($active);
|
||||
|
||||
|
||||
foreach ($ch as $h) {
|
||||
curl_multi_remove_handle ($mh, $h);
|
||||
curl_close ($h);
|
||||
}
|
||||
curl_multi_close ($mh);
|
||||
|
||||
if ($ans_count>0) return $ans_arr;
|
||||
else return $str;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user