[lxc-devel] [lxc/master] lxccontainer: fix non-blocking container stop
brauner on Github
lxc-bot at linuxcontainers.org
Tue Jun 23 09:08:42 UTC 2020
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 449 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200623/2e6b6ad7/attachment.bin>
-------------- next part --------------
From 60cd5091148ce765338915495f6e5e11969608a5 Mon Sep 17 00:00:00 2001
From: Robert Vogelgesang <vogel at folz.de>
Date: Tue, 23 Jun 2020 10:51:33 +0200
Subject: [PATCH] lxccontainer: fix non-blocking container stop
Stopping a lxc container with without waiting on it was broken in master. This
patch fixes it.
Signed-off-by: Robert Vogelgesang <vogel at folz.de>
---
src/lxc/lxccontainer.c | 56 +++++++++++++++++++++---------------------
1 file changed, 28 insertions(+), 28 deletions(-)
diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
index 51422a56de..aac6214825 100644
--- a/src/lxc/lxccontainer.c
+++ b/src/lxc/lxccontainer.c
@@ -2090,41 +2090,41 @@ static bool do_lxcapi_shutdown(struct lxc_container *c, int timeout)
if (ret < MAX_STATE)
return false;
+ }
- if (pidfd >= 0) {
- struct pollfd pidfd_poll = {
- .events = POLLIN,
- .fd = pidfd,
- };
+ if (pidfd >= 0) {
+ struct pollfd pidfd_poll = {
+ .events = POLLIN,
+ .fd = pidfd,
+ };
- killret = lxc_raw_pidfd_send_signal(pidfd, haltsignal,
- NULL, 0);
- if (killret < 0)
- return log_warn(false, "Failed to send signal %d to pidfd %d",
- haltsignal, pidfd);
+ killret = lxc_raw_pidfd_send_signal(pidfd, haltsignal,
+ NULL, 0);
+ if (killret < 0)
+ return log_warn(false, "Failed to send signal %d to pidfd %d",
+ haltsignal, pidfd);
- TRACE("Sent signal %d to pidfd %d", haltsignal, pidfd);
+ TRACE("Sent signal %d to pidfd %d", haltsignal, pidfd);
- /*
- * No need for going through all of the state server
- * complications anymore. We can just poll on pidfds. :)
- */
+ /*
+ * No need for going through all of the state server
+ * complications anymore. We can just poll on pidfds. :)
+ */
- if (timeout != 0) {
- ret = poll(&pidfd_poll, 1, timeout * 1000);
- if (ret < 0 || !(pidfd_poll.revents & POLLIN))
- return false;
+ if (timeout != 0) {
+ ret = poll(&pidfd_poll, 1, timeout * 1000);
+ if (ret < 0 || !(pidfd_poll.revents & POLLIN))
+ return false;
- TRACE("Pidfd polling detected container exit");
- }
- } else {
- killret = kill(pid, haltsignal);
- if (killret < 0)
- return log_warn(false, "Failed to send signal %d to pid %d",
- haltsignal, pid);
-
- TRACE("Sent signal %d to pid %d", haltsignal, pid);
+ TRACE("Pidfd polling detected container exit");
}
+ } else {
+ killret = kill(pid, haltsignal);
+ if (killret < 0)
+ return log_warn(false, "Failed to send signal %d to pid %d",
+ haltsignal, pid);
+
+ TRACE("Sent signal %d to pid %d", haltsignal, pid);
}
if (timeout == 0)
More information about the lxc-devel
mailing list