Kademlia, better treatment when there is no result.
This commit is contained in:
parent
f0bb7375c3
commit
8463e0b06b
1 changed files with 3 additions and 1 deletions
|
@ -447,11 +447,13 @@ struct MultiAddress** search_kademlia(char* peer_id, int timeout)
|
||||||
search_result->ipv4_count == 0 &&
|
search_result->ipv4_count == 0 &&
|
||||||
search_result->ipv6_count == 0) {
|
search_result->ipv6_count == 0) {
|
||||||
to = search_kademlia_internal (id, 0, to); // Repeat search to collect result.
|
to = search_kademlia_internal (id, 0, to); // Repeat search to collect result.
|
||||||
if (to <= 0) return NULL; // time out.
|
|
||||||
usleep(2000000); // Wait a few seconds for the result.
|
usleep(2000000); // Wait a few seconds for the result.
|
||||||
to -= 2000000;
|
to -= 2000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (search_result->ipv4_count == 0 ||
|
||||||
|
search_result->ipv6_count == 0) return NULL; // no result.
|
||||||
|
|
||||||
ret = calloc(search_result->ipv4_count + search_result->ipv6_count + 1, // IPv4 + IPv6 itens and a NULL terminator.
|
ret = calloc(search_result->ipv4_count + search_result->ipv6_count + 1, // IPv4 + IPv6 itens and a NULL terminator.
|
||||||
sizeof (struct MultiAddress*)); // array of pointer.
|
sizeof (struct MultiAddress*)); // array of pointer.
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
|
|
Loading…
Reference in a new issue