Add two new values for the destroy-unattached option to destroy sessions

only if they are not members of sessions groups, from Mark Huang, GitHub
issue 3806.
This commit is contained in:
nicm
2024-02-13 08:10:23 +00:00
parent 4bdb855020
commit 40b97b1715
4 changed files with 39 additions and 9 deletions

View File

@ -454,7 +454,8 @@ server_destroy_session(struct session *s)
void
server_check_unattached(void)
{
struct session *s;
struct session *s;
struct session_group *sg;
/*
* If any sessions are no longer attached and have destroy-unattached
@ -463,8 +464,23 @@ server_check_unattached(void)
RB_FOREACH(s, sessions, &sessions) {
if (s->attached != 0)
continue;
if (options_get_number (s->options, "destroy-unattached"))
session_destroy(s, 1, __func__);
switch (options_get_number(s->options, "destroy-unattached")) {
case 0: /* off */
continue;
case 1: /* on */
break;
case 2: /* keep-last */
sg = session_group_contains(s);
if (sg == NULL || session_group_count(sg) <= 1)
continue;
break;
case 3: /* keep-group */
sg = session_group_contains(s);
if (sg != NULL && session_group_count(sg) == 1)
continue;
break;
}
session_destroy(s, 1, __func__);
}
}