From: Guus Sliepen Date: Sun, 22 May 2011 11:15:27 +0000 (+0200) Subject: Check if an event is initialized before calling event_del(). X-Git-Tag: release-1.1pre1~48 X-Git-Url: https://tinc-vpn.org/git/browse?a=commitdiff_plain;h=8ddcad5fa1908727f68abb461b615c666616064f;p=tinc Check if an event is initialized before calling event_del(). Libevent prints a warning to stderr if we do that. --- diff --git a/src/graph.c b/src/graph.c index bdb32a01..c78615ba 100644 --- a/src/graph.c +++ b/src/graph.c @@ -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 ? : ""); diff --git a/src/net.c b/src/net.c index 0fcc6fae..67603f7d 100644 --- 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; } diff --git a/src/net_socket.c b/src/net_socket.c index 6093f0e0..163553ad 100644 --- a/src/net_socket.c +++ b/src/net_socket.c @@ -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); diff --git a/src/node.c b/src/node.c index 1f1f94d9..3ec9fab1 100644 --- a/src/node.c +++ b/src/node.c @@ -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); diff --git a/src/protocol.c b/src/protocol.c index e866e316..6cb29bf7 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -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); }