summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/cmd-load-buffer.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2010-12-20 00:03:56 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2010-12-20 00:03:56 +0000
commit9f7c689cb8ccc8428baf5d610708ebbb50f2b592 (patch)
treeb09d4e96930f9058c62b67b15e142ec8712a0be9 /usr.bin/tmux/cmd-load-buffer.c
parent38ab20a6f6c33e027490420674d8c89ebf6c07ca (diff)
Unify the way sessions are used by callbacks - store the address and use
the reference count, then check it is still on the global sessions list in the callback.
Diffstat (limited to 'usr.bin/tmux/cmd-load-buffer.c')
-rw-r--r--usr.bin/tmux/cmd-load-buffer.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.bin/tmux/cmd-load-buffer.c b/usr.bin/tmux/cmd-load-buffer.c
index b43f57feb92..3629c6eda87 100644
--- a/usr.bin/tmux/cmd-load-buffer.c
+++ b/usr.bin/tmux/cmd-load-buffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-load-buffer.c,v 1.13 2010/07/24 20:11:59 nicm Exp $ */
+/* $OpenBSD: cmd-load-buffer.c,v 1.14 2010/12/20 00:03:55 nicm Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -81,6 +81,7 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
cdata = xmalloc(sizeof *cdata);
cdata->session = s;
+ cdata->session->references++;
cdata->buffer = data->buffer;
c->stdin_data = cdata;
c->stdin_callback = cmd_load_buffer_callback;
@@ -144,7 +145,6 @@ cmd_load_buffer_callback(struct client *c, void *data)
char *pdata;
size_t psize;
u_int limit;
- int idx;
/*
* Event callback has already checked client is not dead and reduced
@@ -153,7 +153,7 @@ cmd_load_buffer_callback(struct client *c, void *data)
c->flags |= CLIENT_EXIT;
/* Does the target session still exist? */
- if (session_index(s, &idx) != 0)
+ if (!session_alive(s))
goto out;
psize = EVBUFFER_LENGTH(c->stdin_event->input);
@@ -180,5 +180,6 @@ cmd_load_buffer_callback(struct client *c, void *data)
}
out:
+ cdata->session->references--;
xfree(cdata);
}