]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
change defines for return value of handlers
authorDonghwa Jeong <dh48.jeong@samsung.com>
Thu, 31 May 2018 05:54:43 +0000 (14:54 +0900)
committerDonghwa Jeong <dh48.jeong@samsung.com>
Thu, 31 May 2018 05:54:43 +0000 (14:54 +0900)
Signed-off-by: Donghwa Jeong <dh48.jeong@samsung.com>
src/lxc/cmd/lxc_monitord.c [changed mode: 0644->0755]
src/lxc/commands.c [changed mode: 0644->0755]
src/lxc/start.c [changed mode: 0644->0755]
src/lxc/tools/lxc_top.c [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 3b17b67..96f530f
@@ -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)
old mode 100644 (file)
new mode 100755 (executable)
index 1ec6c7e..2121b2e
@@ -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);
old mode 100644 (file)
new mode 100755 (executable)
index a8cd827..8c8a7c3
@@ -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);
old mode 100644 (file)
new mode 100755 (executable)
index 8686938..49630f9
@@ -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[])