]> git.meshlink.io Git - meshlink/blobdiff - src/net_socket.c
Use the canonical address exclusively for making outgoing meta-connections.
[meshlink] / src / net_socket.c
index 5464b95f8071ca57ee479270e32ffcf3c23e0b25..d846237275c023010b07b5aaca342e31f9be7d47 100644 (file)
@@ -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->maxtimeout) {
-               outgoing->timeout = mesh->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) {
@@ -318,7 +320,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) {