]> git.meshlink.io Git - meshlink/blobdiff - src/net_socket.c
Use the fast retry period of the destination node's device class.
[meshlink] / src / net_socket.c
index 51a79c1d4cf54569aa74bdb37f34c297ea306ef0..7ac6dbbdbe023b06033e5e76956b964ff2cdc9b6 100644 (file)
@@ -71,6 +71,11 @@ static void configure_tcp(connection_t *c) {
        int lowdelay = IPTOS_LOWDELAY;
        setsockopt(c->socket, IPPROTO_IP, IP_TOS, (void *)&lowdelay, sizeof(lowdelay));
 #endif
+
+#if defined(SO_NOSIGPIPE)
+       int nosigpipe = 1;
+       setsockopt(c->socket, SOL_SOCKET, SO_NOSIGPIPE, (void *)&nosigpipe, sizeof(nosigpipe));
+#endif
 }
 
 static void retry_outgoing_handler(event_loop_t *loop, void *data) {
@@ -82,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) {