obviously.
-/* $OpenBSD: alerts.c,v 1.18 2017/04/28 19:10:48 nicm Exp $ */
+/* $OpenBSD: alerts.c,v 1.19 2017/04/28 19:13:55 nicm Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicholas.marriott@gmail.com>
TAILQ_REMOVE(&alerts_list, w, alerts_entry);
w->flags &= ~WINDOW_ALERTFLAGS;
- window_remove_ref(w);
+ window_remove_ref(w, __func__);
}
alerts_fired = 0;
}
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) {
-/* $OpenBSD: notify.c,v 1.22 2017/04/21 20:26:34 nicm Exp $ */
+/* $OpenBSD: notify.c,v 1.23 2017/04/28 19:13:55 nicm Exp $ */
/*
* Copyright (c) 2012 George Nachman <tmux@georgester.com>
if (ne->client != NULL)
server_client_unref(ne->client);
if (ne->session != NULL)
- session_unref(ne->session);
+ session_remove_ref(ne->session, __func__);
if (ne->window != NULL)
- window_remove_ref(ne->window);
+ window_remove_ref(ne->window, __func__);
if (ne->fs.s != NULL)
- session_unref(ne->fs.s);
+ session_remove_ref(ne->fs.s, __func__);
free((void *)ne->name);
free(ne);
if (c != NULL)
c->references++;
if (s != NULL)
- s->references++;
+ session_add_ref(s, __func__);
if (w != NULL)
- w->references++;
+ window_add_ref(w, __func__);
cmd_find_copy_state(&ne->fs, fs);
- if (ne->fs.s != NULL)
- ne->fs.s->references++; /* cmd_find_valid_state need session */
+ if (ne->fs.s != NULL) /* cmd_find_valid_state needs session */
+ session_add_ref(ne->fs.s, __func__);
new_item = cmdq_get_callback(notify_callback, ne);
cmdq_append(NULL, new_item);
-/* $OpenBSD: session.c,v 1.74 2017/04/25 15:35:10 nicm Exp $ */
+/* $OpenBSD: session.c,v 1.75 2017/04/28 19:13:55 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
return (s);
}
-/* Remove a reference from a session. */
+/* Add a reference to a session. */
void
-session_unref(struct session *s)
+session_add_ref(struct session *s, const char *from)
{
- log_debug("session %s has %d references", s->name, s->references);
+ s->references++;
+ log_debug("%s: %s %s, now %d", __func__, s->name, from, s->references);
+}
+/* Remove a reference from a session. */
+void
+session_remove_ref(struct session *s, const char *from)
+{
s->references--;
+ log_debug("%s: %s %s, now %d", __func__, s->name, from, s->references);
+
if (s->references == 0)
event_once(-1, EV_TIMEOUT, session_free, s, NULL);
}
free((void *)s->cwd);
- session_unref(s);
+ session_remove_ref(s, __func__);
}
/* Check a session name is valid: not empty and no colons or periods. */
-/* $OpenBSD: tmux.h,v 1.754 2017/04/25 18:30:29 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.755 2017/04/28 19:13:55 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
struct window_pane *window_pane_find_left(struct window_pane *);
struct window_pane *window_pane_find_right(struct window_pane *);
void window_set_name(struct window *, const char *);
-void window_remove_ref(struct window *);
+void window_add_ref(struct window *, const char *);
+void window_remove_ref(struct window *, const char *);
void winlink_clear_flags(struct winlink *);
int winlink_shuffle_up(struct session *, struct winlink *);
const char *, const char *, struct environ *,
struct termios *, int, u_int, u_int, char **);
void session_destroy(struct session *);
-void session_unref(struct session *);
+void session_add_ref(struct session *, const char *);
+void session_remove_ref(struct session *, const char *);
int session_check_name(const char *);
void session_update_activity(struct session *, struct timeval *);
struct session *session_next_session(struct session *);
-/* $OpenBSD: window-choose.c,v 1.88 2017/03/17 14:41:54 nicm Exp $ */
+/* $OpenBSD: window-choose.c,v 1.89 2017/04/28 19:13:55 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
window_choose_data_free(struct window_choose_data *wcd)
{
server_client_unref(wcd->start_client);
- session_unref(wcd->start_session);
+ session_remove_ref(wcd->start_session, __func__);
if (wcd->tree_session != NULL)
- session_unref(wcd->tree_session);
+ session_remove_ref(wcd->tree_session, __func__);
free(wcd->ft_template);
format_free(wcd->ft);
-/* $OpenBSD: window.c,v 1.191 2017/04/28 19:12:15 nicm Exp $ */
+/* $OpenBSD: window.c,v 1.192 2017/04/28 19:13:55 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
{
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
if (w != NULL) {
TAILQ_REMOVE(&w->winlinks, wl, wentry);
- window_remove_ref(w);
+ window_remove_ref(w, __func__);
}
RB_REMOVE(winlinks, wwl, wl);
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);
}
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);
}