Break the common process set up, event loop and imsg dispatch code

between server and client out into a separate internal API. This will
make it easier to add another process.
This commit is contained in:
nicm
2015-10-27 13:23:24 +00:00
parent 9952201ca7
commit 07b0ea03c3
13 changed files with 648 additions and 614 deletions

View File

@ -57,7 +57,7 @@ cmd_detach_client_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_ERROR);
tty_stop_tty(&c->tty);
c->flags |= CLIENT_SUSPENDED;
server_write_client(c, MSG_SUSPEND, NULL, 0);
proc_send(c->peer, MSG_SUSPEND, -1, NULL, 0);
return (CMD_RETURN_NORMAL);
}
@ -74,9 +74,7 @@ cmd_detach_client_exec(struct cmd *self, struct cmd_q *cmdq)
TAILQ_FOREACH(cloop, &clients, entry) {
if (cloop->session != s)
continue;
server_write_client(cloop, msgtype,
cloop->session->name,
strlen(cloop->session->name) + 1);
proc_send_s(cloop->peer, msgtype, cloop->session->name);
}
return (CMD_RETURN_STOP);
}
@ -89,14 +87,11 @@ cmd_detach_client_exec(struct cmd *self, struct cmd_q *cmdq)
TAILQ_FOREACH(cloop, &clients, entry) {
if (cloop->session == NULL || cloop == c)
continue;
server_write_client(cloop, msgtype,
cloop->session->name,
strlen(cloop->session->name) + 1);
proc_send_s(cloop->peer, msgtype, cloop->session->name);
}
return (CMD_RETURN_NORMAL);
}
server_write_client(c, msgtype, c->session->name,
strlen(c->session->name) + 1);
proc_send_s(c->peer, msgtype, c->session->name);
return (CMD_RETURN_STOP);
}