From 6e210bb005ee5193fe030f5e8cfe8877aac6260d Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Mon, 27 Aug 2007 12:05:15 +0000 Subject: If a session is destroyed, safely kill all other clients attached to it. --- session.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'session.c') diff --git a/session.c b/session.c index 169a04cd..7066d624 100644 --- a/session.c +++ b/session.c @@ -1,4 +1,4 @@ -/* $Id: session.c,v 1.3 2007-08-27 09:53:38 nicm Exp $ */ +/* $Id: session.c,v 1.4 2007-08-27 12:05:15 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -119,7 +119,7 @@ session_attach(struct session *s, struct window *w) } /* Detach a window from a session. */ -int +void session_detach(struct session *s, struct window *w) { if (s->window == w) { @@ -128,13 +128,20 @@ session_detach(struct session *s, struct window *w) } window_remove(&s->windows, w); - if (ARRAY_EMPTY(&s->windows)) { - session_destroy(s); - return (1); - } return (0); } +/* Flush session if it is empty. */ +int +session_flush(struct session *s) +{ + if (!ARRAY_EMPTY(&s->windows)) + return (0); + + session_destroy(s); + return (1); +} + /* Return if session has window. */ int session_has(struct session *s, struct window *w) -- cgit