Unconditionally remove timeouts from the queue before calling the callback.
[oweals/tinc.git] / src / event.c
index 331872a5b378d324a66818d34891861e62bde721..33d205a96f52c1e58b8e1f42150c11ad6633b0a6 100644 (file)
@@ -300,11 +300,9 @@ static struct timeval *get_time_remaining(struct timeval *diff) {
                timersub(&timeout->tv, &now, diff);
 
                if(diff->tv_sec < 0) {
-                       timeout->cb(timeout->data);
-
-                       if(timercmp(&timeout->tv, &now, <)) {
-                               timeout_del(timeout);
-                       }
+                       timeout_cb_t cb = timeout->cb;
+                       timeout_del(timeout);
+                       cb(timeout->data);
                } else {
                        tv = diff;
                        break;