diff options
author | nicm <nicm> | 2017-04-28 19:13:55 +0000 |
---|---|---|
committer | nicm <nicm> | 2017-04-28 19:13:55 +0000 |
commit | 0f2f783584c62879a1182972e915f550bf23f00a (patch) | |
tree | a516d196841ac2f8e478e068a2a7e3c946f7a186 /window.c | |
parent | bcd6b416749cbac712c29ee07049e98c5930c800 (diff) | |
download | rtmux-0f2f783584c62879a1182972e915f550bf23f00a.tar.gz rtmux-0f2f783584c62879a1182972e915f550bf23f00a.tar.bz2 rtmux-0f2f783584c62879a1182972e915f550bf23f00a.zip |
Log what is happening with window and session reference counts much more
obviously.
Diffstat (limited to 'window.c')
-rw-r--r-- | window.c | 22 |
1 files changed, 14 insertions, 8 deletions
@@ -186,11 +186,11 @@ winlink_set_window(struct winlink *wl, struct window *w) { if (wl->window != NULL) { TAILQ_REMOVE(&wl->window->winlinks, wl, wentry); - window_remove_ref(wl->window); + window_remove_ref(wl->window, __func__); } TAILQ_INSERT_TAIL(&w->winlinks, wl, wentry); wl->window = w; - w->references++; + window_add_ref(w, __func__); } void @@ -200,7 +200,7 @@ winlink_remove(struct winlinks *wwl, struct winlink *wl) if (w != NULL) { TAILQ_REMOVE(&w->winlinks, wl, wentry); - window_remove_ref(w); + window_remove_ref(w, __func__); } RB_REMOVE(winlinks, wwl, wl); @@ -361,8 +361,7 @@ window_create_spawn(const char *name, int argc, char **argv, const char *path, static void window_destroy(struct window *w) { - if (!TAILQ_EMPTY(&w->winlinks)) - fatalx("window destroyed with winlinks"); + log_debug("window @%u destroyed (%d references)", w->id, w->references); RB_REMOVE(windows, &windows, w); @@ -387,11 +386,18 @@ window_destroy(struct window *w) } void -window_remove_ref(struct window *w) +window_add_ref(struct window *w, const char *from) +{ + w->references++; + log_debug("%s: @%u %s, now %d", __func__, w->id, from, w->references); +} + +void +window_remove_ref(struct window *w, const char *from) { - if (w->references == 0) - fatal("bad reference count"); w->references--; + log_debug("%s: @%u %s, now %d", __func__, w->id, from, w->references); + if (w->references == 0) window_destroy(w); } |