X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fnet_socket.c;h=d1a5df99a05f2e42b4ea9eaea335e1b3cf0dc3d4;hb=1f9c1231139d2a93ef4ace9891013d2c23cdf4ae;hp=6d1d8fb386952f1e49ea12fc0d9e7ca5740efe30;hpb=06a9d580c37d80c680c3dda2ff8f3c53f487c735;p=meshlink diff --git a/src/net_socket.c b/src/net_socket.c index 6d1d8fb3..d1a5df99 100644 --- a/src/net_socket.c +++ b/src/net_socket.c @@ -481,14 +481,18 @@ static bool get_next_outgoing_address(meshlink_handle_t *mesh, outgoing_t *outgo } if(outgoing->state == OUTGOING_KNOWN) { - if(outgoing->aip || get_recent(mesh, outgoing)) { - if(get_next_ai(mesh, outgoing)) { - return true; - } else { - free_known_addresses(outgoing->ai); - outgoing->ai = NULL; - outgoing->aip = NULL; - } + if(!outgoing->aip) { + get_recent(mesh, outgoing); + } else { + outgoing->aip = outgoing->aip->ai_next; + } + + if(outgoing->aip) { + return true; + } else { + free_known_addresses(outgoing->ai); + outgoing->ai = NULL; + outgoing->aip = NULL; } outgoing->state = OUTGOING_END;