X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fnet_socket.c;h=a692313958850a0f1b87db3bb313930684cb59b9;hb=4b6c01b1d5383b1a7417244a31ad4652aab2d5db;hp=8b293d5d548904002fe7e15749bf938fcb478f3f;hpb=53818faa72ac501f593edfc454b35d1fd4bfb318;p=meshlink diff --git a/src/net_socket.c b/src/net_socket.c index 8b293d5d..a6923139 100644 --- a/src/net_socket.c +++ b/src/net_socket.c @@ -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) { @@ -88,8 +93,10 @@ void retry_outgoing(meshlink_handle_t *mesh, outgoing_t *outgoing) { 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) { @@ -283,12 +290,14 @@ static bool get_next_outgoing_address(meshlink_handle_t *mesh, outgoing_t *outgo if(port) { *port++ = 0; port = xstrdup(port); + adns_queue(mesh, address, port, canonical_resolve_cb, outgoing->node, 2); + return false; } else { - port = xstrdup(mesh->myport); + logger(mesh, MESHLINK_ERROR, "Canonical address for %s is missing port number", n->name); + free(address); + outgoing->state = OUTGOING_RECENT; } - adns_queue(mesh, address, port, canonical_resolve_cb, outgoing->node, 2); - return false; } else { outgoing->state = OUTGOING_RECENT; }