X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fnet_socket.c;h=abf6a7cf0e0eb7fa878f347efa45a6910c646927;hb=a23ddd4f4e273b2ed68fe173b4faa69aadc98756;hp=6af4f7386bcc37530057fc5251de2ff0103a1137;hpb=da55b444c063c510f37e4f8527982eb86f01c7b3;p=meshlink diff --git a/src/net_socket.c b/src/net_socket.c index 6af4f738..abf6a7cf 100644 --- a/src/net_socket.c +++ b/src/net_socket.c @@ -87,14 +87,16 @@ 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; } - if(outgoing->timeout > mesh->dev_class_traits[mesh->devclass].maxtimeout) { - outgoing->timeout = mesh->dev_class_traits[mesh->devclass].maxtimeout; + int maxtimeout = mesh->dev_class_traits[outgoing->node->devclass].maxtimeout; + + if(outgoing->timeout > maxtimeout) { + outgoing->timeout = maxtimeout; } timeout_add(&mesh->loop, &outgoing->ev, retry_outgoing_handler, outgoing, &(struct timespec) { @@ -141,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; @@ -318,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) {