Fixed typos. When terminating a connection, it's status is not only set to
[tinc] / src / net.c
index b6007b4..60b7b79 100644 (file)
--- a/src/net.c
+++ b/src/net.c
@@ -654,8 +654,8 @@ cp
 
   if(connect(nfd, (struct sockaddr *)&a, sizeof(a)) == -1)
     {
-      syslog(LOG_ERR, "Create connection to %08lx:%d failed: %m", ntohs(cl->real_ip),
-            cl->port);
+      syslog(LOG_ERR, "Connecting to " IP_ADDR_S ":%d failed: %m",
+            IP_ADDR_V(cl->real_ip), cl->port);
       return -1;
     }
 
@@ -821,11 +821,12 @@ cp
 
   if(cl->status.outgoing)
     {
-      alarm(5);
       signal(SIGALRM, sigalrm_handler);
+      alarm(5);
       syslog(LOG_NOTICE, "Try to re-establish outgoing connection in 5 seconds.");
     }
   
+  cl->status.active = 0;
   cl->status.remove = 1;
 cp
 }
@@ -851,21 +852,22 @@ cp
       if(p->status.active && p->status.meta)
        {
           if(p->last_ping_time + timeout < now)
-            if(p->status.pinged && !p->status.got_pong)
-              {
-               syslog(LOG_INFO, "%s (" IP_ADDR_S ") didn't respond to ping",
-                      p->hostname, IP_ADDR_V(p->vpn_ip));
-               p->status.timeout = 1;
-               terminate_connection(p);
-              }
-            else if(p->want_ping)
-              {
-                send_ping(p);
-                p->last_ping_time = now;
-                p->status.pinged = 1;
-                p->status.get_pong = 0;
-              }
-          }
+            {
+              if(p->status.pinged && !p->status.got_pong)
+                {
+                 syslog(LOG_INFO, "%s (" IP_ADDR_S ") didn't respond to ping",
+                        p->hostname, IP_ADDR_V(p->vpn_ip));
+                 p->status.timeout = 1;
+                 terminate_connection(p);
+                }
+              else if(p->want_ping)
+                {
+                  send_ping(p);
+                  p->last_ping_time = now;
+                  p->status.pinged = 1;
+                  p->status.got_pong = 0;
+                }
+            }
        }
     }
 cp