X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fnet_socket.c;h=8983d2895aede8dc603dcb164cd3e2e1d6c96629;hb=34ea20af73a35cd918ce9dc25796bebf9493b49c;hp=97d6c448265ce62a03c5707045897e6ce917c901;hpb=0267aef826ba627aba3a525b36c0e7bfc0f9a221;p=tinc diff --git a/src/net_socket.c b/src/net_socket.c index 97d6c448..8983d289 100644 --- a/src/net_socket.c +++ b/src/net_socket.c @@ -1,7 +1,7 @@ /* net_socket.c -- Handle various kinds of sockets. Copyright (C) 1998-2005 Ivo Timmermans, - 2000-2014 Guus Sliepen + 2000-2016 Guus Sliepen 2006 Scott Lamb 2009 Florian Forster @@ -82,6 +82,11 @@ static void configure_tcp(connection_t *c) { option = IPTOS_LOWDELAY; setsockopt(c->socket, SOL_IP, IP_TOS, (void *)&option, sizeof option); #endif + +#if defined(IPPROTO_IPV6) && defined(IPV6_TCLASS) && defined(IPTOS_LOWDELAY) + option = IPTOS_LOWDELAY; + setsockopt(c->socket, IPPROTO_IPV6, IPV6_TCLASS, (void *)&option, sizeof option); +#endif } static bool bind_to_interface(int sd) { @@ -547,6 +552,7 @@ begin: /* Now that there is a working socket, fill in the rest and register this connection. */ + c->last_ping_time = time(NULL); c->status.connecting = true; c->name = xstrdup(outgoing->name); #ifndef DISABLE_LEGACY @@ -604,9 +610,12 @@ void setup_outgoing_connection(outgoing_t *outgoing) { if(n && n->connection) { logger(DEBUG_CONNECTIONS, LOG_INFO, "Already connected to %s", outgoing->name); - - n->connection->outgoing = outgoing; - return; + if(!n->connection->outgoing) { + n->connection->outgoing = outgoing; + return; + } else { + goto remove; + } } init_configuration(&outgoing->config_tree); @@ -618,11 +627,15 @@ void setup_outgoing_connection(outgoing_t *outgoing) { outgoing->aip = outgoing->ai = get_known_addresses(n); if(!outgoing->ai) { logger(DEBUG_ALWAYS, LOG_DEBUG, "No address known for %s", outgoing->name); - return; + goto remove; } } do_outgoing_connection(outgoing); + return; + +remove: + list_delete(outgoing_list, outgoing); } /*