If a session is destroyed, safely kill all other clients attached to it.

This commit is contained in:
Nicholas Marriott
2007-08-27 12:05:15 +00:00
parent 7000277f94
commit 6e210bb005
3 changed files with 41 additions and 17 deletions

View File

@ -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 <nicm@users.sourceforge.net>
@ -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)