X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fnet_socket.c;h=7e05ab9362b4ecd9d6d81b268a25ff75d8f25f93;hb=3fe7713c4f9d16f192271bc4fa8a2ffda6bb28fd;hp=eb9e3fc41f98fca0fe15bf8d0b998425e69553fd;hpb=529b8fab8c21e7ae5af91d742ff202eab38e51f3;p=meshlink 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;