blast: Fix segfault for immediate connection.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 2 Apr 2008 08:10:53 +0000 (09:10 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 2 Apr 2008 08:10:53 +0000 (09:10 +0100)
This manifests itself when run under noip, which uses Unix-domain sockets
instead.  The problem is to do with the timer, which isn't active at the
the that conn_init is called.

blast.c

diff --git a/blast.c b/blast.c
index 597263e..60ef0f7 100644 (file)
--- a/blast.c
+++ b/blast.c
@@ -112,13 +112,14 @@ static void newconn(blast *b)
     goto fail;
   gettimeofday(&tv, 0);
   TV_ADD(&tv, &tv, &ctv);
+  sel_addtimer(&sel, &b->t, &tv, timeout, b);
   if (conn_init(&b->c, &sel, fd, (struct sockaddr *)&sin, sizeof(sin),
                connected, b))
     goto fail;
-  sel_addtimer(&sel, &b->t, &tv, timeout, b);
   return;
 
 fail:
+  sel_rmtimer(&b->t);
   backoff(b);
 }