change defines for return value of handlers

Signed-off-by: Donghwa Jeong <dh48.jeong@samsung.com>
This commit is contained in:
Donghwa Jeong 2018-05-31 14:54:43 +09:00
parent ed40d791c4
commit b2a4850853
4 changed files with 14 additions and 14 deletions

8
src/lxc/cmd/lxc_monitord.c Normal file → Executable file
View File

@ -161,7 +161,7 @@ static int lxc_monitord_sock_handler(int fd, uint32_t events, void *data,
rc = read(fd, buf, sizeof(buf));
if (rc > 0 && !strncmp(buf, "quit", 4))
quit = 1;
quit = LXC_MAINLOOP_CLOSE;
}
if (events & EPOLLHUP)
@ -177,7 +177,7 @@ static int lxc_monitord_sock_accept(int fd, uint32_t events, void *data,
struct ucred cred;
socklen_t credsz = sizeof(cred);
ret = -1;
ret = LXC_MAINLOOP_ERROR;
clientfd = accept(fd, NULL, 0);
if (clientfd < 0) {
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));
if (ret != sizeof(msglxc)) {
SYSERROR("Reading from fifo failed: %s.", strerror(errno));
return 1;
return LXC_MAINLOOP_CLOSE;
}
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));
}
return 0;
return LXC_MAINLOOP_CONTINUE;
}
static int lxc_monitord_mainloop_add(struct lxc_monitor *mon)

6
src/lxc/commands.c Normal file → Executable file
View File

@ -1167,7 +1167,7 @@ static int lxc_cmd_handler(int fd, uint32_t events, void *data,
if (ret != req.datalen) {
WARN("Failed to receive full command request. Ignoring "
"request for \"%s\"", lxc_cmd_str(req.cmd));
ret = -1;
ret = LXC_MAINLOOP_ERROR;
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);
if (ret) {
/* This is not an error, but only a request to close fd. */
ret = 0;
ret = LXC_MAINLOOP_CONTINUE;
goto out_close;
}
@ -1201,7 +1201,7 @@ static int lxc_cmd_accept(int fd, uint32_t events, void *data,
connection = accept(fd, NULL, 0);
if (connection < 0) {
SYSERROR("Failed to accept connection to run command.");
return -1;
return LXC_MAINLOOP_ERROR;
}
ret = fcntl(connection, F_SETFD, FD_CLOEXEC);

12
src/lxc/start.c Normal file → Executable file
View File

@ -343,7 +343,7 @@ static int signal_handler(int fd, uint32_t events, void *data,
ret = read(fd, &siginfo, sizeof(siginfo));
if (ret < 0) {
ERROR("Failed to read signal info from signal file descriptor %d", fd);
return -1;
return LXC_MAINLOOP_ERROR;
}
if (ret != sizeof(siginfo)) {
@ -382,13 +382,13 @@ static int signal_handler(int fd, uint32_t events, void *data,
if (siginfo.ssi_signo == SIGHUP) {
kill(hdlr->pid, SIGTERM);
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) {
kill(hdlr->pid, siginfo.ssi_signo);
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
@ -397,15 +397,15 @@ static int signal_handler(int fd, uint32_t events, void *data,
if (siginfo.ssi_pid != hdlr->pid) {
NOTICE("Received %d from pid %d instead of container init %d",
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) {
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) {
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);

2
src/lxc/tools/lxc_top.c Normal file → Executable file
View File

@ -671,7 +671,7 @@ static int stdin_handler(int fd, uint32_t events, void *data,
if (events & EPOLLHUP)
*in_char = 'q';
return 1;
return LXC_MAINLOOP_CLOSE;
}
int main(int argc, char *argv[])