Improve UDP address selection.
[tinc] / src / net_socket.c
index 36da2d0..ce1e3aa 100644 (file)
@@ -63,7 +63,7 @@ static void configure_tcp(connection_t *c) {
        unsigned long arg = 1;
 
        if(ioctlsocket(c->socket, FIONBIO, &arg) != 0) {
-               logger(DEBUG_ALWAYS, LOG_ERR, "ioctlsocket for %s: %d", c->hostname, sockstrerror(sockerrno));
+               logger(DEBUG_ALWAYS, LOG_ERR, "ioctlsocket for %s: %s", c->hostname, sockstrerror(sockerrno));
        }
 #endif
 
@@ -282,7 +282,7 @@ void retry_outgoing(outgoing_t *outgoing) {
                outgoing->timeout = maxtimeout;
 
        timeout_set(&outgoing->ev, retry_outgoing_handler, outgoing);
-       event_add(&outgoing->ev, &(struct timeval){outgoing->timeout, 0});
+       event_add(&outgoing->ev, &(struct timeval){outgoing->timeout, rand() % 100000});
 
        logger(DEBUG_CONNECTIONS, LOG_NOTICE,
                           "Trying to re-establish outgoing connection in %d seconds",
@@ -555,7 +555,7 @@ void handle_new_meta_connection(int sock, short events, void *data) {
        event_set(&c->inevent, c->socket, EV_READ | EV_PERSIST, handle_meta_connection_data, c);
        event_set(&c->outevent, c->socket, EV_WRITE | EV_PERSIST, handle_meta_write, c);
        event_add(&c->inevent, NULL);
-               
+
        configure_tcp(c);
 
        connection_add(c);