1
0
mirror of https://github.com/Yubico/yubikey-val.git synced 2024-11-29 00:24:13 +01:00

Push more outgoing syncs in parallel

This commit is contained in:
Nigel Williams 2020-02-17 09:30:15 +11:00
parent 18ced7b6e7
commit 2217c0a4be
No known key found for this signature in database
GPG Key ID: 669BF2ED84BDDE8B

View File

@ -305,21 +305,26 @@ class SyncLib
} }
$this->db->closeCursor($server_res); $this->db->closeCursor($server_res);
/* add one entry for each server we're going to sync */ $num_per_server = 4;
/* add up to n entries for each server we're going to sync */
foreach ($server_list as $server) { foreach ($server_list as $server) {
$entry = array_shift($server); $items = array_slice($server, 0, $num_per_server);
foreach ($items as $entry) {
$handle = $ch[$entry['server']];
$this->log(LOG_INFO, "server=" . $entry['server'] . ", server_nonce=" . $entry['server_nonce'] . ", info=" . $entry['info']);
$url = $this->buildSyncUrl($entry);
curl_settings($this, 'YK-VAL resync', $handle, $url, $timeout, $this->curlopts);
$entries[$entry['server']] = $entry;
curl_multi_add_handle($mh, $handle);
$handles++;
}
$empty = array();
array_splice($server, 0, $num_per_server, $empty);
if(count($server) == 0) { if(count($server) == 0) {
unset($server_list[$entry['server']]); unset($server_list[$entry['server']]);
} }
$handle = $ch[$entry['server']];
$this->log(LOG_INFO, "server=" . $entry['server'] . ", server_nonce=" . $entry['server_nonce'] . ", info=" . $entry['info']);
$url = $this->buildSyncUrl($entry);
curl_settings($this, 'YK-VAL resync', $handle, $url, $timeout, $this->curlopts);
$entries[$entry['server']] = $entry;
curl_multi_add_handle($mh, $handle);
$handles++;
} }
while($handles > 0) { while($handles > 0) {