mirror of
https://github.com/tmux/tmux.git
synced 2024-12-12 17:38:48 +00:00
Wake up any clients waiting with the wait-for command when the server
exits.
This commit is contained in:
parent
4e956d545a
commit
733cea8847
@ -194,3 +194,25 @@ cmd_wait_for_unlock(struct cmd_q *cmdq, const char *name,
|
|||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_wait_for_flush(void)
|
||||||
|
{
|
||||||
|
struct wait_channel *wc, *wc1;
|
||||||
|
struct cmd_q *wq, *wq1;
|
||||||
|
|
||||||
|
RB_FOREACH_SAFE(wc, wait_channels, &wait_channels, wc1) {
|
||||||
|
TAILQ_FOREACH_SAFE(wq, &wc->waiters, waitentry, wq1) {
|
||||||
|
TAILQ_REMOVE(&wc->waiters, wq, waitentry);
|
||||||
|
if (!cmdq_free(wq))
|
||||||
|
cmdq_continue(wq);
|
||||||
|
}
|
||||||
|
while ((wq = TAILQ_FIRST(&wc->lockers)) != NULL) {
|
||||||
|
TAILQ_REMOVE(&wc->lockers, wq, waitentry);
|
||||||
|
if (!cmdq_free(wq))
|
||||||
|
cmdq_continue(wq);
|
||||||
|
}
|
||||||
|
RB_REMOVE(wait_channels, &wait_channels, wc);
|
||||||
|
free((void *)wc->name);
|
||||||
|
free(wc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
18
server.c
18
server.c
@ -217,16 +217,30 @@ server_loop(void)
|
|||||||
int
|
int
|
||||||
server_should_shutdown(void)
|
server_should_shutdown(void)
|
||||||
{
|
{
|
||||||
u_int i;
|
struct client *c;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
if (!options_get_number(&global_options, "exit-unattached")) {
|
if (!options_get_number(&global_options, "exit-unattached")) {
|
||||||
if (!RB_EMPTY(&sessions))
|
if (!RB_EMPTY(&sessions))
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
|
c = ARRAY_ITEM(&clients, i);
|
||||||
|
if (c != NULL && c->session != NULL)
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* No attached clients therefore want to exit - flush any waiting
|
||||||
|
* clients but don't actually exit until they've gone.
|
||||||
|
*/
|
||||||
|
cmd_wait_for_flush();
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
if (ARRAY_ITEM(&clients, i) != NULL)
|
if (ARRAY_ITEM(&clients, i) != NULL)
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,6 +252,8 @@ server_send_shutdown(void)
|
|||||||
struct session *s, *next_s;
|
struct session *s, *next_s;
|
||||||
u_int i;
|
u_int i;
|
||||||
|
|
||||||
|
cmd_wait_for_flush();
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
c = ARRAY_ITEM(&clients, i);
|
c = ARRAY_ITEM(&clients, i);
|
||||||
if (c != NULL) {
|
if (c != NULL) {
|
||||||
|
3
tmux.h
3
tmux.h
@ -1924,6 +1924,9 @@ void cmdq_flush(struct cmd_q *);
|
|||||||
int cmd_string_parse(const char *, struct cmd_list **, const char *,
|
int cmd_string_parse(const char *, struct cmd_list **, const char *,
|
||||||
u_int, char **);
|
u_int, char **);
|
||||||
|
|
||||||
|
/* cmd-wait-for.c */
|
||||||
|
void cmd_wait_for_flush(void);
|
||||||
|
|
||||||
/* client.c */
|
/* client.c */
|
||||||
int client_main(int, char **, int);
|
int client_main(int, char **, int);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user