Don't rearm rs timer if callback is not set
authorHans Dedecker <hans.dedecker@technicolor.com>
Wed, 15 Jan 2014 13:46:44 +0000 (14:46 +0100)
committerHans Dedecker <hans.dedecker@technicolor.com>
Wed, 15 Jan 2014 13:46:44 +0000 (14:46 +0100)
src/router.c

index a75b847..dfbcf60 100644 (file)
@@ -451,12 +451,14 @@ static void send_router_advert(struct uloop_timeout *event)
        odhcpd_send(router_event.uloop.fd,
                        &all_nodes, iov, ARRAY_SIZE(iov), iface);
 
        odhcpd_send(router_event.uloop.fd,
                        &all_nodes, iov, ARRAY_SIZE(iov), iface);
 
-       // Rearm timer
-       int msecs;
-       odhcpd_urandom(&msecs, sizeof(msecs));
-       msecs = (labs(msecs) % (1000 * (MaxRtrAdvInterval
-                       - MinRtrAdvInterval))) + (MinRtrAdvInterval * 1000);
-       uloop_timeout_set(&iface->timer_rs, msecs);
+       // Rearm timer if not shut down
+       if (event->cb) {
+               int msecs;
+               odhcpd_urandom(&msecs, sizeof(msecs));
+               msecs = (labs(msecs) % (1000 * (MaxRtrAdvInterval
+                               - MinRtrAdvInterval))) + (MinRtrAdvInterval * 1000);
+               uloop_timeout_set(&iface->timer_rs, msecs);
+       }
 }
 
 
 }