]> git.meshlink.io Git - meshlink/commitdiff
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 bdb32a01622d351cf9f5e9fdc80822262ba3d1b3..c78615ba871a2e7ad69bf2046ab59ffb694b951f 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 0fcc6fae31b4c590fad73d92fa65bc31608679b0..67603f7d277f66969e5a63d48013c71d0aee4c01 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 6093f0e028ffa2118011e1dea5daeaa39640dc96..163553ad3de22374e4c13ea287438f98efe28f71 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 1f1f94d9625363e4205213fbeb9610c237b6a4b7..3ec9fab1f7f1d70c97ce01be14f558ec7fdb2fc9 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 e866e3165ef19f3e3c29686365d024dff6e03e7f..6cb29bf73d250f4524ffd5778629d47a1fb9d6f1 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);
 }