Sync OpenBSD patchset 1057:

Check event_initialized before event_del if event may not have been set
up; libevent2 complains about this. Reported by Moriyoshi Koizumi.
This commit is contained in:
Tiago Cunha 2012-03-18 01:59:34 +00:00
parent 5aa28473dd
commit 0987d55231
7 changed files with 22 additions and 11 deletions

View File

@ -36,6 +36,7 @@ queue_window_name(struct window *w)
tv.tv_sec = 0;
tv.tv_usec = NAME_INTERVAL * 1000L;
if (event_initialized(&w->name_timer))
evtimer_del(&w->name_timer);
evtimer_set(&w->name_timer, window_name_callback, w);
evtimer_add(&w->name_timer, &tv);

View File

@ -152,10 +152,12 @@ server_client_lost(struct client *c)
evtimer_del(&c->repeat_timer);
if (event_initialized(&c->identify_timer))
evtimer_del(&c->identify_timer);
if (c->message_string != NULL)
xfree(c->message_string);
if (event_initialized (&c->message_timer))
evtimer_del(&c->message_timer);
for (i = 0; i < ARRAY_LENGTH(&c->message_log); i++) {
msg = &ARRAY_ITEM(&c->message_log, i);
@ -175,6 +177,7 @@ server_client_lost(struct client *c)
close(c->ibuf.fd);
imsg_clear(&c->ibuf);
if (event_initialized(&c->event))
event_del(&c->event);
for (i = 0; i < ARRAY_LENGTH(&dead_clients); i++) {

View File

@ -453,6 +453,7 @@ server_set_identify(struct client *c)
tv.tv_sec = delay / 1000;
tv.tv_usec = (delay % 1000) * 1000L;
if (event_initialized (&c->identify_timer))
evtimer_del(&c->identify_timer);
evtimer_set(&c->identify_timer, server_callback_identify, c);
evtimer_add(&c->identify_timer, &tv);
@ -491,6 +492,7 @@ server_update_event(struct client *c)
events |= EV_READ;
if (c->ibuf.w.queued > 0)
events |= EV_WRITE;
if (event_initialized(&c->event))
event_del(&c->event);
event_set(&c->event, c->ibuf.fd, events, server_client_callback, c);
event_add(&c->event, NULL);

View File

@ -776,6 +776,7 @@ status_message_set(struct client *c, const char *fmt, ...)
tv.tv_sec = delay / 1000;
tv.tv_usec = (delay % 1000) * 1000L;
if (event_initialized (&c->message_timer))
evtimer_del(&c->message_timer);
evtimer_set(&c->message_timer, status_message_callback, c);
evtimer_add(&c->message_timer, &tv);

View File

@ -549,6 +549,7 @@ start_timer:
tv.tv_sec = delay / 1000;
tv.tv_usec = (delay % 1000) * 1000L;
if (event_initialized(&tty->key_timer))
evtimer_del(&tty->key_timer);
evtimer_set(&tty->key_timer, tty_keys_callback, tty);
evtimer_add(&tty->key_timer, &tv);
@ -573,6 +574,7 @@ found_key:
goto handle_key;
handle_key:
if (event_initialized(&tty->key_timer))
evtimer_del(&tty->key_timer);
if (key != KEYC_NONE)

1
tty.c
View File

@ -279,6 +279,7 @@ tty_close(struct tty *tty)
tty->log_fd = -1;
}
if (event_initialized(&tty->key_timer))
evtimer_del(&tty->key_timer);
tty_stop_tty(tty);

View File

@ -347,6 +347,7 @@ window_destroy(struct window *w)
if (w->layout_root != NULL)
layout_free(w);
if (event_initialized(&w->name_timer))
evtimer_del(&w->name_timer);
options_free(&w->options);