diff options
author | dimitri staessens <dimitri.staessens@ugent.be> | 2017-09-19 20:53:08 +0000 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@ugent.be> | 2017-09-19 20:53:08 +0000 |
commit | 90a389066512761921f79617122695c676664b75 (patch) | |
tree | 71e69e0d721c99505d6dc2bcdc9b67625e9947e4 /src/ipcpd/normal | |
parent | acd8235533d63a7e4dd4d1b5bdb17423d4b6fd75 (diff) | |
parent | 4758fe231a096d23a8ec1861df2ff2f796035819 (diff) | |
download | ouroboros-90a389066512761921f79617122695c676664b75.tar.gz ouroboros-90a389066512761921f79617122695c676664b75.zip |
Merged in dstaesse/ouroboros/be-dht-contacts (pull request #599)
ipcpd: Fix contact list in DHT
Diffstat (limited to 'src/ipcpd/normal')
-rw-r--r-- | src/ipcpd/normal/dht.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/ipcpd/normal/dht.c b/src/ipcpd/normal/dht.c index e4c37884..a5d324f0 100644 --- a/src/ipcpd/normal/dht.c +++ b/src/ipcpd/normal/dht.c @@ -567,12 +567,12 @@ static size_t dht_contact_list(struct dht * dht, c = list_entry(p, struct contact, next); c = contact_create(c->id, dht->b, c->addr); if (list_add_sorted(l, c, key) == 1) - if (++len > dht->k) + if (++len == dht->k) break; } } else { struct bucket * d = b->parent; - for (i = 0; i < (1L << KAD_BETA); ++i) { + for (i = 0; i < (1L << KAD_BETA) && len < dht->k; ++i) { list_for_each(p, &d->children[i]->contacts) { struct contact * c; c = list_entry(p, struct contact, next); @@ -580,7 +580,7 @@ static size_t dht_contact_list(struct dht * dht, if (c == NULL) continue; if (list_add_sorted(l, c, key) == 1) - if (++len > dht->k) + if (++len == dht->k) break; } } |