mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-07-26 22:11:46 +00:00
change defines for return value of handlers
Signed-off-by: Donghwa Jeong <dh48.jeong@samsung.com>
This commit is contained in:
parent
ed40d791c4
commit
b2a4850853
8
src/lxc/cmd/lxc_monitord.c
Normal file → Executable file
8
src/lxc/cmd/lxc_monitord.c
Normal file → Executable file
@ -161,7 +161,7 @@ static int lxc_monitord_sock_handler(int fd, uint32_t events, void *data,
|
|||||||
|
|
||||||
rc = read(fd, buf, sizeof(buf));
|
rc = read(fd, buf, sizeof(buf));
|
||||||
if (rc > 0 && !strncmp(buf, "quit", 4))
|
if (rc > 0 && !strncmp(buf, "quit", 4))
|
||||||
quit = 1;
|
quit = LXC_MAINLOOP_CLOSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (events & EPOLLHUP)
|
if (events & EPOLLHUP)
|
||||||
@ -177,7 +177,7 @@ static int lxc_monitord_sock_accept(int fd, uint32_t events, void *data,
|
|||||||
struct ucred cred;
|
struct ucred cred;
|
||||||
socklen_t credsz = sizeof(cred);
|
socklen_t credsz = sizeof(cred);
|
||||||
|
|
||||||
ret = -1;
|
ret = LXC_MAINLOOP_ERROR;
|
||||||
clientfd = accept(fd, NULL, 0);
|
clientfd = accept(fd, NULL, 0);
|
||||||
if (clientfd < 0) {
|
if (clientfd < 0) {
|
||||||
SYSERROR("Failed to accept connection for client file descriptor %d.", fd);
|
SYSERROR("Failed to accept connection for client file descriptor %d.", fd);
|
||||||
@ -301,7 +301,7 @@ static int lxc_monitord_fifo_handler(int fd, uint32_t events, void *data,
|
|||||||
ret = read(fd, &msglxc, sizeof(msglxc));
|
ret = read(fd, &msglxc, sizeof(msglxc));
|
||||||
if (ret != sizeof(msglxc)) {
|
if (ret != sizeof(msglxc)) {
|
||||||
SYSERROR("Reading from fifo failed: %s.", strerror(errno));
|
SYSERROR("Reading from fifo failed: %s.", strerror(errno));
|
||||||
return 1;
|
return LXC_MAINLOOP_CLOSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < mon->clientfds_cnt; i++) {
|
for (i = 0; i < mon->clientfds_cnt; i++) {
|
||||||
@ -311,7 +311,7 @@ static int lxc_monitord_fifo_handler(int fd, uint32_t events, void *data,
|
|||||||
mon->clientfds[i], strerror(errno));
|
mon->clientfds[i], strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return LXC_MAINLOOP_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lxc_monitord_mainloop_add(struct lxc_monitor *mon)
|
static int lxc_monitord_mainloop_add(struct lxc_monitor *mon)
|
||||||
|
6
src/lxc/commands.c
Normal file → Executable file
6
src/lxc/commands.c
Normal file → Executable file
@ -1167,7 +1167,7 @@ static int lxc_cmd_handler(int fd, uint32_t events, void *data,
|
|||||||
if (ret != req.datalen) {
|
if (ret != req.datalen) {
|
||||||
WARN("Failed to receive full command request. Ignoring "
|
WARN("Failed to receive full command request. Ignoring "
|
||||||
"request for \"%s\"", lxc_cmd_str(req.cmd));
|
"request for \"%s\"", lxc_cmd_str(req.cmd));
|
||||||
ret = -1;
|
ret = LXC_MAINLOOP_ERROR;
|
||||||
goto out_close;
|
goto out_close;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1177,7 +1177,7 @@ static int lxc_cmd_handler(int fd, uint32_t events, void *data,
|
|||||||
ret = lxc_cmd_process(fd, &req, handler);
|
ret = lxc_cmd_process(fd, &req, handler);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
/* This is not an error, but only a request to close fd. */
|
/* This is not an error, but only a request to close fd. */
|
||||||
ret = 0;
|
ret = LXC_MAINLOOP_CONTINUE;
|
||||||
goto out_close;
|
goto out_close;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1201,7 +1201,7 @@ static int lxc_cmd_accept(int fd, uint32_t events, void *data,
|
|||||||
connection = accept(fd, NULL, 0);
|
connection = accept(fd, NULL, 0);
|
||||||
if (connection < 0) {
|
if (connection < 0) {
|
||||||
SYSERROR("Failed to accept connection to run command.");
|
SYSERROR("Failed to accept connection to run command.");
|
||||||
return -1;
|
return LXC_MAINLOOP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = fcntl(connection, F_SETFD, FD_CLOEXEC);
|
ret = fcntl(connection, F_SETFD, FD_CLOEXEC);
|
||||||
|
12
src/lxc/start.c
Normal file → Executable file
12
src/lxc/start.c
Normal file → Executable file
@ -343,7 +343,7 @@ static int signal_handler(int fd, uint32_t events, void *data,
|
|||||||
ret = read(fd, &siginfo, sizeof(siginfo));
|
ret = read(fd, &siginfo, sizeof(siginfo));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
ERROR("Failed to read signal info from signal file descriptor %d", fd);
|
ERROR("Failed to read signal info from signal file descriptor %d", fd);
|
||||||
return -1;
|
return LXC_MAINLOOP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret != sizeof(siginfo)) {
|
if (ret != sizeof(siginfo)) {
|
||||||
@ -382,13 +382,13 @@ static int signal_handler(int fd, uint32_t events, void *data,
|
|||||||
if (siginfo.ssi_signo == SIGHUP) {
|
if (siginfo.ssi_signo == SIGHUP) {
|
||||||
kill(hdlr->pid, SIGTERM);
|
kill(hdlr->pid, SIGTERM);
|
||||||
INFO("Killing %d since terminal hung up", hdlr->pid);
|
INFO("Killing %d since terminal hung up", hdlr->pid);
|
||||||
return hdlr->init_died ? LXC_MAINLOOP_CLOSE : 0;
|
return hdlr->init_died ? LXC_MAINLOOP_CLOSE : LXC_MAINLOOP_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (siginfo.ssi_signo != SIGCHLD) {
|
if (siginfo.ssi_signo != SIGCHLD) {
|
||||||
kill(hdlr->pid, siginfo.ssi_signo);
|
kill(hdlr->pid, siginfo.ssi_signo);
|
||||||
INFO("Forwarded signal %d to pid %d", siginfo.ssi_signo, hdlr->pid);
|
INFO("Forwarded signal %d to pid %d", siginfo.ssi_signo, hdlr->pid);
|
||||||
return hdlr->init_died ? LXC_MAINLOOP_CLOSE : 0;
|
return hdlr->init_died ? LXC_MAINLOOP_CLOSE : LXC_MAINLOOP_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* More robustness, protect ourself from a SIGCHLD sent
|
/* More robustness, protect ourself from a SIGCHLD sent
|
||||||
@ -397,15 +397,15 @@ static int signal_handler(int fd, uint32_t events, void *data,
|
|||||||
if (siginfo.ssi_pid != hdlr->pid) {
|
if (siginfo.ssi_pid != hdlr->pid) {
|
||||||
NOTICE("Received %d from pid %d instead of container init %d",
|
NOTICE("Received %d from pid %d instead of container init %d",
|
||||||
siginfo.ssi_signo, siginfo.ssi_pid, hdlr->pid);
|
siginfo.ssi_signo, siginfo.ssi_pid, hdlr->pid);
|
||||||
return hdlr->init_died ? LXC_MAINLOOP_CLOSE : 0;
|
return hdlr->init_died ? LXC_MAINLOOP_CLOSE : LXC_MAINLOOP_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (siginfo.ssi_code == CLD_STOPPED) {
|
if (siginfo.ssi_code == CLD_STOPPED) {
|
||||||
INFO("Container init process was stopped");
|
INFO("Container init process was stopped");
|
||||||
return hdlr->init_died ? LXC_MAINLOOP_CLOSE : 0;
|
return hdlr->init_died ? LXC_MAINLOOP_CLOSE : LXC_MAINLOOP_CONTINUE;
|
||||||
} else if (siginfo.ssi_code == CLD_CONTINUED) {
|
} else if (siginfo.ssi_code == CLD_CONTINUED) {
|
||||||
INFO("Container init process was continued");
|
INFO("Container init process was continued");
|
||||||
return hdlr->init_died ? LXC_MAINLOOP_CLOSE : 0;
|
return hdlr->init_died ? LXC_MAINLOOP_CLOSE : LXC_MAINLOOP_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG("Container init process %d exited", hdlr->pid);
|
DEBUG("Container init process %d exited", hdlr->pid);
|
||||||
|
2
src/lxc/tools/lxc_top.c
Normal file → Executable file
2
src/lxc/tools/lxc_top.c
Normal file → Executable file
@ -671,7 +671,7 @@ static int stdin_handler(int fd, uint32_t events, void *data,
|
|||||||
|
|
||||||
if (events & EPOLLHUP)
|
if (events & EPOLLHUP)
|
||||||
*in_char = 'q';
|
*in_char = 'q';
|
||||||
return 1;
|
return LXC_MAINLOOP_CLOSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
Loading…
Reference in New Issue
Block a user