Instead of putting dead clients on a list and checking it every loop,

use event_once to queue a callback to deal with them. Also dead clients
with references would never actually be freed because the wrap-up
functions (the callback for stdin, or status_prompt_clear) would never
be called. So call them in server_client_lost.
This commit is contained in:
nicm
2015-06-05 18:01:12 +00:00
parent b0782df8a6
commit 8c93b768e4
5 changed files with 37 additions and 16 deletions

View File

@ -41,9 +41,7 @@
* Main server functions.
*/
/* Client list. */
struct clients clients;
struct clients dead_clients;
int server_fd;
int server_shutdown;
@ -205,7 +203,6 @@ server_start(int lockfd, char *lockfile)
RB_INIT(&windows);
RB_INIT(&all_window_panes);
TAILQ_INIT(&clients);
TAILQ_INIT(&dead_clients);
RB_INIT(&sessions);
RB_INIT(&dead_sessions);
TAILQ_INIT(&session_groups);
@ -325,7 +322,6 @@ void
server_clean_dead(void)
{
struct session *s, *s1;
struct client *c, *c1;
RB_FOREACH_SAFE(s, sessions, &dead_sessions, s1) {
if (s->references != 0)
@ -334,13 +330,6 @@ server_clean_dead(void)
free(s->name);
free(s);
}
TAILQ_FOREACH_SAFE(c, &dead_clients, entry, c1) {
if (c->references != 0)
continue;
TAILQ_REMOVE(&dead_clients, c, entry);
free(c);
}
}
/* Update socket execute permissions based on whether sessions are attached. */