From b2a48508539294c40bc03ae505bc4f620e6414ce Mon Sep 17 00:00:00 2001 From: Donghwa Jeong Date: Thu, 31 May 2018 14:54:43 +0900 Subject: [PATCH] change defines for return value of handlers Signed-off-by: Donghwa Jeong --- src/lxc/cmd/lxc_monitord.c | 8 ++++---- src/lxc/commands.c | 6 +++--- src/lxc/start.c | 12 ++++++------ src/lxc/tools/lxc_top.c | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) mode change 100644 => 100755 src/lxc/cmd/lxc_monitord.c mode change 100644 => 100755 src/lxc/commands.c mode change 100644 => 100755 src/lxc/start.c mode change 100644 => 100755 src/lxc/tools/lxc_top.c diff --git a/src/lxc/cmd/lxc_monitord.c b/src/lxc/cmd/lxc_monitord.c old mode 100644 new mode 100755 index 3b17b67d4..96f530fec --- a/src/lxc/cmd/lxc_monitord.c +++ b/src/lxc/cmd/lxc_monitord.c @@ -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) diff --git a/src/lxc/commands.c b/src/lxc/commands.c old mode 100644 new mode 100755 index 1ec6c7e70..2121b2e6b --- a/src/lxc/commands.c +++ b/src/lxc/commands.c @@ -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); diff --git a/src/lxc/start.c b/src/lxc/start.c old mode 100644 new mode 100755 index a8cd82771..8c8a7c3aa --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -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); diff --git a/src/lxc/tools/lxc_top.c b/src/lxc/tools/lxc_top.c old mode 100644 new mode 100755 index 868693866..49630f91b --- a/src/lxc/tools/lxc_top.c +++ b/src/lxc/tools/lxc_top.c @@ -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[]) -- 2.39.5