summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/session.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/tmux/session.c')
-rw-r--r--usr.bin/tmux/session.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/usr.bin/tmux/session.c b/usr.bin/tmux/session.c
index ae52de4fdbb..456f13a2364 100644
--- a/usr.bin/tmux/session.c
+++ b/usr.bin/tmux/session.c
@@ -1,4 +1,4 @@
-/* $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>
@@ -189,13 +189,21 @@ session_create(const char *prefix, const char *name, int argc, char **argv,
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);
}
@@ -248,7 +256,7 @@ session_destroy(struct session *s)
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. */