diff options
author | Tiago Cunha <tcunha@gmx.com> | 2009-09-07 23:59:19 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2009-09-07 23:59:19 +0000 |
commit | 930f67f4740b2ecca065be653339d5cf51c9a19f (patch) | |
tree | 5e8e6e2bb91cb3d682354bb0bfdbfd399d8e63f5 /session.c | |
parent | 1de812d5a8342afc2498c0ef74f4fcbf48907d0b (diff) | |
download | rtmux-930f67f4740b2ecca065be653339d5cf51c9a19f.tar.gz rtmux-930f67f4740b2ecca065be653339d5cf51c9a19f.tar.bz2 rtmux-930f67f4740b2ecca065be653339d5cf51c9a19f.zip |
Sync OpenBSD patchset 320:
Reference count clients and sessions rather than relying on a saved index for
cmd-choose-*.
Diffstat (limited to 'session.c')
-rw-r--r-- | session.c | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -1,4 +1,4 @@ -/* $Id: session.c,v 1.64 2009-09-02 01:05:55 tcunha Exp $ */ +/* $Id: session.c,v 1.65 2009-09-07 23:59:19 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -27,6 +27,7 @@ /* Global session list. */ struct sessions sessions; +struct sessions dead_sessions; struct winlink *session_next_activity(struct session *, struct winlink *); struct winlink *session_previous_activity(struct session *, struct winlink *); @@ -120,14 +121,19 @@ session_create(const char *name, const char *cmd, const char *cwd, u_int i; s = xmalloc(sizeof *s); + s->references = 0; s->flags = 0; + if (gettimeofday(&s->tv, NULL) != 0) fatal("gettimeofday"); + s->curw = NULL; SLIST_INIT(&s->lastw); RB_INIT(&s->windows); SLIST_INIT(&s->alerts); + paste_init_stack(&s->buffers); + options_init(&s->options, &global_s_options); environ_init(&s->environ); if (env != NULL) @@ -186,7 +192,16 @@ session_destroy(struct session *s) winlink_remove(&s->windows, RB_ROOT(&s->windows)); xfree(s->name); - xfree(s); + + for (i = 0; i < ARRAY_LENGTH(&dead_sessions); i++) { + if (ARRAY_ITEM(&dead_sessions, i) == NULL) { + ARRAY_SET(&dead_sessions, i, s); + break; + } + } + if (i == ARRAY_LENGTH(&dead_sessions)) + ARRAY_ADD(&dead_sessions, s); + s->flags |= SESSION_DEAD; } /* Find session index. */ |