X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fnet_socket.c;h=dd02bf33bb7bbe26fed204c0066befa4f447005e;hb=6cc23a673bcd2e310c96be5cd658a18676026442;hp=a692313958850a0f1b87db3bb313930684cb59b9;hpb=40507802ddac36012a59beec96cb02060f8d0293;p=meshlink diff --git a/src/net_socket.c b/src/net_socket.c index a6923139..dd02bf33 100644 --- a/src/net_socket.c +++ b/src/net_socket.c @@ -87,7 +87,7 @@ static void retry_outgoing_handler(event_loop_t *loop, void *data) { } void retry_outgoing(meshlink_handle_t *mesh, outgoing_t *outgoing) { - if(!mesh->reachable && mesh->loop.now.tv_sec < mesh->last_unreachable + mesh->dev_class_traits[mesh->devclass].fast_retry_period) { + if(!mesh->reachable && mesh->loop.now.tv_sec < mesh->last_unreachable + mesh->dev_class_traits[outgoing->node->devclass].fast_retry_period) { outgoing->timeout = 1; } else { outgoing->timeout += 5; @@ -143,6 +143,10 @@ static void handle_meta_write(meshlink_handle_t *mesh, connection_t *c) { } } +void flush_meta(meshlink_handle_t *mesh, connection_t *c) { + handle_meta_write(mesh, c); +} + static void handle_meta_io(event_loop_t *loop, void *data, int flags) { meshlink_handle_t *mesh = loop->data; connection_t *c = data; @@ -320,7 +324,7 @@ static bool get_next_outgoing_address(meshlink_handle_t *mesh, outgoing_t *outgo outgoing->ai = NULL; outgoing->aip = NULL; - outgoing->state = OUTGOING_RECENT; + outgoing->state = OUTGOING_END; } if(outgoing->state == OUTGOING_RECENT) { @@ -374,6 +378,7 @@ begin: /* We are waiting for a callback from the ADNS thread */ } else if(outgoing->state == OUTGOING_NO_KNOWN_ADDRESSES) { logger(mesh, MESHLINK_ERROR, "No known addresses for %s", outgoing->node->name); + list_delete(mesh->outgoings, outgoing); } else { logger(mesh, MESHLINK_ERROR, "Could not set up a meta connection to %s", outgoing->node->name); retry_outgoing(mesh, outgoing); @@ -520,6 +525,10 @@ void handle_new_meta_connection(event_loop_t *loop, void *data, int flags) { fd = accept(l->tcp.fd, &sa.sa, &len); if(fd < 0) { + if(sockwouldblock(errno)) { + return; + } + if(errno == EINVAL) { // TODO: check if Windows agrees event_loop_stop(loop); return;