Hello,
I noticed some random crashes after sending SIGHUP to the daemon
(especially when some connections are continually failling).
Playing around with gdb, it seems that after SIGHUP, all the
"outgoing"
information of the connections is being cleared, but later on it is
being used in other places while still equal to NULL.
The attached patch tries to fix this by avoiding these conditions. It
works for me, although it might not be the best way to fix it, since I'm
not yet very familiar with tinc's data structures.
Regards,
--
Ga?l Roualland -+- gael.roualland@dial.oleane.com
-------------- next part --------------
diff -ru tinc-1.0.4/src/net.c tinc-1.0.4.gr/src/net.c
--- tinc-1.0.4/src/net.c Wed May 4 20:09:37 2005
+++ tinc-1.0.4.gr/src/net.c Wed May 17 23:02:38 2006
@@ -248,7 +248,7 @@
}
ifdebug(CONNECTIONS) logger(LOG_WARNING, _("Timeout from %s (%s)
during authentication"),
c->name, c->hostname);
- if(c->status.connecting) {
+ if(c->status.connecting && c->outgoing) {
c->status.connecting = false;
closesocket(c->socket);
do_outgoing_connection(c);
@@ -297,7 +297,10 @@
_("Error while connecting to %s (%s): %s"),
c->name, c->hostname, strerror(result));
closesocket(c->socket);
- do_outgoing_connection(c);
+ if (c->outgoing)
+ do_outgoing_connection(c);
+ else
+ terminate_connection(c, false);
continue;
}
}
@@ -427,13 +430,14 @@
}
/* Close connections to hosts that have a changed or deleted host config
file */
-
for(node = connection_tree->head; node; node = node->next) {
c = node->data;
-
+
if(c->outgoing) {
- free(c->outgoing->name);
- freeaddrinfo(c->outgoing->ai);
+ if (c->outgoing->name)
+ free(c->outgoing->name);
+ if (c->outgoing->ai)
+ freeaddrinfo(c->outgoing->ai);
free(c->outgoing);
c->outgoing = NULL;
}