X-Git-Url: http://git.meshlink.io/?p=meshlink;a=blobdiff_plain;f=src%2Fnet_socket.c;h=7e05ab9362b4ecd9d6d81b268a25ff75d8f25f93;hp=eb9e3fc41f98fca0fe15bf8d0b998425e69553fd;hb=42874d60e2554393094ea5cc1325ab2984750cbc;hpb=a97a07d79c847d0b30c61a2589e7bde62f25d603 diff --git a/src/net_socket.c b/src/net_socket.c index eb9e3fc4..7e05ab93 100644 --- a/src/net_socket.c +++ b/src/net_socket.c @@ -592,6 +592,20 @@ begin: io_add(&mesh->loop, &c->io, handle_meta_io, c, c->socket, IO_READ | IO_WRITE); } +void reset_outgoing(outgoing_t *outgoing) { + if(outgoing->ai) { + if(outgoing->state == OUTGOING_RECENT || outgoing->state == OUTGOING_KNOWN) { + free_known_addresses(outgoing->ai); + } else { + freeaddrinfo(outgoing->ai); + } + } + + outgoing->ai = NULL; + outgoing->aip = NULL; + outgoing->state = OUTGOING_START; +} + void setup_outgoing_connection(meshlink_handle_t *mesh, outgoing_t *outgoing) { timeout_del(&mesh->loop, &outgoing->ev); @@ -602,16 +616,7 @@ void setup_outgoing_connection(meshlink_handle_t *mesh, outgoing_t *outgoing) { return; } - - if(outgoing->ai) { - if(outgoing->state == OUTGOING_RECENT || outgoing->state == OUTGOING_KNOWN) { - free_known_addresses(outgoing->ai); - } else { - freeaddrinfo(outgoing->ai); - } - } - - outgoing->state = OUTGOING_START; + reset_outgoing(outgoing); if(outgoing->node->status.blacklisted) { return;