Check if an event is initialized before calling event_del().

Libevent prints a warning to stderr if we do that.
This commit is contained in:
Guus Sliepen 2011-05-22 13:15:27 +02:00
parent 931e30f91a
commit 8ddcad5fa1
5 changed files with 12 additions and 6 deletions

View 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 ? : "");

View file

@ -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;
}

View 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);

View 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);

View 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);
}