From 92053cb4924e5c772ba52aca83437cf3da0a75fd Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 28 Apr 2017 19:10:48 +0000 Subject: Do not put the window on the alerts queue and add a reference unless the alert is enabled and we are actually going to add the alerts event. --- alerts.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'alerts.c') diff --git a/alerts.c b/alerts.c index 708a24e2..f4a3520c 100644 --- a/alerts.c +++ b/alerts.c @@ -144,16 +144,18 @@ alerts_queue(struct window *w, int flags) log_debug("@%u alerts flags added %#x", w->id, flags); } - if (!w->alerts_queued) { - w->alerts_queued = 1; - TAILQ_INSERT_TAIL(&alerts_list, w, alerts_entry); - w->references++; - } + if (alerts_enabled(w, flags)) { + if (!w->alerts_queued) { + w->alerts_queued = 1; + TAILQ_INSERT_TAIL(&alerts_list, w, alerts_entry); + w->references++; + } - if (!alerts_fired && alerts_enabled(w, flags)) { - log_debug("alerts check queued (by @%u)", w->id); - event_once(-1, EV_TIMEOUT, alerts_callback, NULL, NULL); - alerts_fired = 1; + if (!alerts_fired) { + log_debug("alerts check queued (by @%u)", w->id); + event_once(-1, EV_TIMEOUT, alerts_callback, NULL, NULL); + alerts_fired = 1; + } } } -- cgit From 0f2f783584c62879a1182972e915f550bf23f00a Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 28 Apr 2017 19:13:55 +0000 Subject: Log what is happening with window and session reference counts much more obviously. --- alerts.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'alerts.c') diff --git a/alerts.c b/alerts.c index f4a3520c..6696369f 100644 --- a/alerts.c +++ b/alerts.c @@ -64,7 +64,7 @@ alerts_callback(__unused int fd, __unused short events, __unused void *arg) TAILQ_REMOVE(&alerts_list, w, alerts_entry); w->flags &= ~WINDOW_ALERTFLAGS; - window_remove_ref(w); + window_remove_ref(w, __func__); } alerts_fired = 0; } @@ -148,7 +148,7 @@ alerts_queue(struct window *w, int flags) if (!w->alerts_queued) { w->alerts_queued = 1; TAILQ_INSERT_TAIL(&alerts_list, w, alerts_entry); - w->references++; + window_add_ref(w, __func__); } if (!alerts_fired) { -- cgit