list_delete() already free()s the deleted element.
[tinc] / src / net_socket.c
index 85bc4df..767e91e 100644 (file)
@@ -43,8 +43,8 @@
 int addressfamily = AF_UNSPEC;
 int maxtimeout = 900;
 int seconds_till_retry = 5;
-int udp_rcvbuf = 0;
-int udp_sndbuf = 0;
+int udp_rcvbuf = 1024 * 1024;
+int udp_sndbuf = 1024 * 1024;
 int max_connection_burst = 100;
 
 listen_socket_t listen_socket[MAXSOCKETS];
@@ -604,9 +604,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);
@@ -617,12 +620,16 @@ void setup_outgoing_connection(outgoing_t *outgoing) {
                if(n)
                        outgoing->aip = outgoing->ai = get_known_addresses(n);
                if(!outgoing->ai) {
-                       logger(DEBUG_ALWAYS, LOG_ERR, "No address known for %s", outgoing->name);
-                       return;
+                       logger(DEBUG_ALWAYS, LOG_DEBUG, "No address known for %s", outgoing->name);
+                       goto remove;
                }
        }
 
        do_outgoing_connection(outgoing);
+       return;
+
+remove:
+       list_delete(outgoing_list, outgoing);
 }
 
 /*
@@ -800,6 +807,11 @@ void try_outgoing_connections(void) {
                        continue;
                }
 
+               if(!strcmp(name, myself->name)) {
+                       free(name);
+                       continue;
+               }
+
                bool found = false;
 
                for list_each(outgoing_t, outgoing, outgoing_list) {