summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Rettberg2013-09-17 15:31:03 +0200
committerSimon Rettberg2013-09-17 15:31:03 +0200
commitaba8aa92d7049676a96aa026d9cf5ad7d552f0fa (patch)
treede17247b35c7db924f72af8bd19a82e8130f37ee /src
parent[SERVER] Typo... (diff)
downloaddnbd3-aba8aa92d7049676a96aa026d9cf5ad7d552f0fa.tar.gz
dnbd3-aba8aa92d7049676a96aa026d9cf5ad7d552f0fa.tar.xz
dnbd3-aba8aa92d7049676a96aa026d9cf5ad7d552f0fa.zip
[SERVER] Fix generation of alt-server list for client
Diffstat (limited to 'src')
-rw-r--r--src/server/altservers.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/server/altservers.c b/src/server/altservers.c
index 5e4cebd..39132ad 100644
--- a/src/server/altservers.c
+++ b/src/server/altservers.c
@@ -183,13 +183,12 @@ int altservers_getMatching(dnbd3_host_t *host, dnbd3_server_entry_t *output, int
for (j = 0; j < size; ++j) {
if ( j < count && dist <= distance[j] ) continue;
if ( j > count ) break; // Should never happen but just in case...
- if ( j < count ) {
+ if ( j < count && j + 1 < size ) {
// Check if we're in the middle and need to move other entries...
- if ( j + 1 < size ) {
- memmove( &output[j + 1], &output[j], sizeof(dnbd3_server_entry_t) * (size - j - 1) );
- memmove( &distance[j + 1], &distance[j], sizeof(int) * (size - j - 1) );
- }
- } else {
+ memmove( &output[j + 1], &output[j], sizeof(dnbd3_server_entry_t) * (size - j - 1) );
+ memmove( &distance[j + 1], &distance[j], sizeof(int) * (size - j - 1) );
+ }
+ if ( count < size ) {
count++;
}
output[j].host = _alt_servers[i].host;
@@ -266,6 +265,7 @@ static unsigned int altservers_updateRtt(const dnbd3_host_t * const host, const
* Determine how close two addresses are to each other by comparing the number of
* matching bits from the left of the address. Does not count individual bits but
* groups of 4 for speed.
+ * Return: Closeness - higher number means closer
*/
int altservers_netCloseness(dnbd3_host_t *host1, dnbd3_host_t *host2)
{