diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-09-12 13:01:20 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-09-12 13:01:20 +0000 |
commit | 9b17dcefb91d8e0e7d156399fb05eda011e43f61 (patch) | |
tree | a130171f3c2e15b6f81c87bde762113d22f2f13e /usr.bin | |
parent | 13e531ff99d51e80b2e641e2d8afabe342841620 (diff) |
Tidy some common code for destroying sessions into a new function.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/server-fn.c | 38 | ||||
-rw-r--r-- | usr.bin/tmux/server.c | 20 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 3 |
3 files changed, 28 insertions, 33 deletions
diff --git a/usr.bin/tmux/server-fn.c b/usr.bin/tmux/server-fn.c index 2697fc070ed..549f2512aed 100644 --- a/usr.bin/tmux/server-fn.c +++ b/usr.bin/tmux/server-fn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-fn.c,v 1.18 2009/09/05 17:42:16 nicm Exp $ */ +/* $OpenBSD: server-fn.c,v 1.19 2009/09/12 13:01:19 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -272,10 +272,7 @@ server_kill_window(struct window *w) { struct session *s; struct winlink *wl; - struct client *c; - u_int i, j; - int destroyed; - + u_int i; for (i = 0; i < ARRAY_LENGTH(&sessions); i++) { s = ARRAY_ITEM(&sessions, i); @@ -284,23 +281,30 @@ server_kill_window(struct window *w) if ((wl = winlink_find_by_window(&s->windows, w)) == NULL) continue; - destroyed = session_detach(s, wl); - for (j = 0; j < ARRAY_LENGTH(&clients); j++) { - c = ARRAY_ITEM(&clients, j); - if (c == NULL || c->session != s) - continue; - - if (destroyed) { - c->session = NULL; - server_write_client(c, MSG_EXIT, NULL, 0); - } else - server_redraw_client(c); - } + if (session_detach(s, wl)) + server_destroy_session(s); + else + server_redraw_session(s); } recalculate_sizes(); } void +server_destroy_session(struct session *s) +{ + struct client *c; + u_int i; + + for (i = 0; i < ARRAY_LENGTH(&clients); i++) { + c = ARRAY_ITEM(&clients, i); + if (c == NULL || c->session != s) + continue; + c->session = NULL; + server_write_client(c, MSG_EXIT, NULL, 0); + } +} + +void server_set_identify(struct client *c) { struct timeval tv; diff --git a/usr.bin/tmux/server.c b/usr.bin/tmux/server.c index f0bfcc20dbe..d0e2a7f7c6e 100644 --- a/usr.bin/tmux/server.c +++ b/usr.bin/tmux/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.33 2009/09/10 17:16:24 nicm Exp $ */ +/* $OpenBSD: server.c,v 1.34 2009/09/12 13:01:19 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -1211,21 +1211,11 @@ server_check_window(struct window *w) RB_FOREACH(wl, winlinks, &s->windows) { if (wl->window != w) continue; - destroyed = session_detach(s, wl); - for (j = 0; j < ARRAY_LENGTH(&clients); j++) { - c = ARRAY_ITEM(&clients, j); - if (c == NULL || c->session != s) - continue; - if (!destroyed) { - server_redraw_client(c); - continue; - } - c->session = NULL; - server_write_client(c, MSG_EXIT, NULL, 0); - } - /* If the session was destroyed, bail now. */ - if (destroyed) + if (session_detach(s, wl)) { + server_destroy_session(s); break; + } + server_redraw_session(s); goto restart; } } diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 06152be4145..71b38bc1901 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.102 2009/09/10 17:16:24 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.103 2009/09/12 13:01:19 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -1457,6 +1457,7 @@ void server_status_window(struct window *); void server_lock(void); int server_unlock(const char *); void server_kill_window(struct window *); +void server_destroy_session(struct session *); void server_set_identify(struct client *); void server_clear_identify(struct client *); |