Commit 43eb6f29 by Daniel Lezcano Committed by Daniel Lezcano

fix multiple console for a container

Don't close the socket when we ask for a console, otherwise this will make the console slot to be freed, so the next console will use the same slot leading to an erratic behavior. Signed-off-by: 's avatarDaniel Lezcano <daniel.lezcano@free.fr>
parent 7ee895e4
......@@ -69,8 +69,8 @@ static int receive_answer(int sock, struct lxc_answer *answer)
return ret;
}
extern int lxc_command(const char *name, struct lxc_command *command,
int *stopped)
static int __lxc_command(const char *name, struct lxc_command *command,
int *stopped, int stay_connected)
{
int sock, ret = -1;
char path[sizeof(((struct sockaddr_un *)0)->sun_path)] = { 0 };
......@@ -103,10 +103,25 @@ extern int lxc_command(const char *name, struct lxc_command *command,
ret = receive_answer(sock, &command->answer);
out:
if (!stay_connected || ret < 0)
close(sock);
return ret;
}
extern int lxc_command(const char *name,
struct lxc_command *command, int *stopped)
{
return __lxc_command(name, command, stopped, 0);
}
extern int lxc_command_connected(const char *name,
struct lxc_command *command, int *stopped)
{
return __lxc_command(name, command, stopped, 1);
}
pid_t get_init_pid(const char *name)
{
struct lxc_command command = {
......
......@@ -48,9 +48,13 @@ struct lxc_command {
};
extern pid_t get_init_pid(const char *name);
extern int lxc_command(const char *name, struct lxc_command *command,
int *stopped);
extern int lxc_command_connected(const char *name, struct lxc_command *command,
int *stopped);
struct lxc_epoll_descr;
struct lxc_handler;
......
......@@ -47,7 +47,7 @@ extern int lxc_console(const char *name, int ttynum, int *fd)
.request = { .type = LXC_COMMAND_TTY, .data = ttynum },
};
ret = lxc_command(name, &command, &stopped);
ret = lxc_command_connected(name, &command, &stopped);
if (ret < 0 && stopped) {
ERROR("'%s' is stopped", name);
return -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment