Check if an event is initialized before calling event_del().
authorGuus Sliepen <guus@tinc-vpn.org>
Sun, 22 May 2011 11:15:27 +0000 (13:15 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Sun, 22 May 2011 11:24:01 +0000 (13:24 +0200)
Libevent prints a warning to stderr if we do that.

src/graph.c
src/net.c
src/net_socket.c
src/node.c
src/protocol.c

index bdb32a0..c78615b 100644 (file)
@@ -349,7 +349,8 @@ void check_reachability() {
                        n->minmtu = 0;
                        n->mtuprobes = 0;
 
-                       event_del(&n->mtuevent);
+                       if(timeout_initialized(&n->mtuevent))
+                               event_del(&n->mtuevent);
 
                        xasprintf(&envp[0], "NETNAME=%s", netname ? : "");
                        xasprintf(&envp[1], "DEVICE=%s", device ? : "");
index 0fcc6fa..67603f7 100644 (file)
--- a/src/net.c
+++ b/src/net.c
@@ -375,7 +375,9 @@ int main_loop(void) {
        signal_del(&sighup_event);
        signal_del(&sigterm_event);
        signal_del(&sigquit_event);
-       event_del(&timeout_event);
+
+       if(timeout_initialized(&timeout_event))
+               event_del(&timeout_event);
 
        return 0;
 }
index 6093f0e..163553a 100644 (file)
@@ -462,7 +462,7 @@ void handle_meta_write(int sock, short events, void *data) {
        }
 
        buffer_read(&c->outbuf, outlen);
-       if(!c->outbuf.len)
+       if(!c->outbuf.len && event_initialized(&c->outevent))
                event_del(&c->outevent);
 }
 
@@ -476,7 +476,8 @@ void setup_outgoing_connection(outgoing_t *outgoing) {
        connection_t *c;
        node_t *n;
 
-       event_del(&outgoing->ev);
+       if(event_initialized(&outgoing->ev))
+               event_del(&outgoing->ev);
 
        n = lookup_node(outgoing->name);
 
index 1f1f94d..3ec9fab 100644 (file)
@@ -85,7 +85,8 @@ void free_node(node_t *n) {
        cipher_close(&n->outcipher);
        digest_close(&n->outdigest);
 
-       event_del(&n->mtuevent);
+       if(timeout_initialized(&n->mtuevent))
+               event_del(&n->mtuevent);
        
        if(n->hostname)
                free(n->hostname);
index e866e31..6cb29bf 100644 (file)
@@ -228,5 +228,6 @@ void init_requests(void) {
 void exit_requests(void) {
        splay_delete_tree(past_request_tree);
 
-       event_del(&past_request_event);
+       if(timeout_initialized(&past_request_event))
+               event_del(&past_request_event);
 }