Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
08eccae8
Unverified
Commit
08eccae8
authored
Mar 11, 2020
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lxccontainer: switch to pidfd polling when shutting down containers
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
9837ee46
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
7 deletions
+25
-7
lxccontainer.c
src/lxc/lxccontainer.c
+25
-7
No files found.
src/lxc/lxccontainer.c
View file @
08eccae8
...
@@ -2094,11 +2094,9 @@ static bool do_lxcapi_shutdown(struct lxc_container *c, int timeout)
...
@@ -2094,11 +2094,9 @@ static bool do_lxcapi_shutdown(struct lxc_container *c, int timeout)
return
true
;
return
true
;
pidfd
=
do_lxcapi_init_pidfd
(
c
);
pidfd
=
do_lxcapi_init_pidfd
(
c
);
if
(
pidfd
<
0
)
{
pid
=
do_lxcapi_init_pid
(
c
);
pid
=
do_lxcapi_init_pid
(
c
);
if
(
pid
<=
0
)
if
(
pid
<=
0
)
return
true
;
return
true
;
}
/* Detect whether we should send SIGRTMIN + 3 (e.g. systemd). */
/* Detect whether we should send SIGRTMIN + 3 (e.g. systemd). */
if
(
c
->
lxc_conf
&&
c
->
lxc_conf
->
haltsignal
)
if
(
c
->
lxc_conf
&&
c
->
lxc_conf
->
haltsignal
)
...
@@ -2106,8 +2104,10 @@ static bool do_lxcapi_shutdown(struct lxc_container *c, int timeout)
...
@@ -2106,8 +2104,10 @@ static bool do_lxcapi_shutdown(struct lxc_container *c, int timeout)
else
if
(
task_blocks_signal
(
pid
,
(
SIGRTMIN
+
3
)))
else
if
(
task_blocks_signal
(
pid
,
(
SIGRTMIN
+
3
)))
haltsignal
=
(
SIGRTMIN
+
3
);
haltsignal
=
(
SIGRTMIN
+
3
);
/* Add a new state client before sending the shutdown signal so that we
* don't miss a state.
/*
* Add a new state client before sending the shutdown signal so
* that we don't miss a state.
*/
*/
if
(
timeout
!=
0
)
{
if
(
timeout
!=
0
)
{
states
[
STOPPED
]
=
1
;
states
[
STOPPED
]
=
1
;
...
@@ -2124,16 +2124,33 @@ static bool do_lxcapi_shutdown(struct lxc_container *c, int timeout)
...
@@ -2124,16 +2124,33 @@ static bool do_lxcapi_shutdown(struct lxc_container *c, int timeout)
if
(
ret
<
MAX_STATE
)
if
(
ret
<
MAX_STATE
)
return
false
;
return
false
;
}
/* Send shutdown signal to container. */
if
(
pidfd
>=
0
)
{
if
(
pidfd
>=
0
)
{
killret
=
lxc_raw_pidfd_send_signal
(
pidfd
,
haltsignal
,
NULL
,
0
);
struct
pollfd
pidfd_poll
=
{
.
events
=
POLLIN
,
.
fd
=
pidfd
,
};
killret
=
lxc_raw_pidfd_send_signal
(
pidfd
,
haltsignal
,
NULL
,
0
);
if
(
killret
<
0
)
if
(
killret
<
0
)
return
log_warn
(
false
,
"Failed to send signal %d to pidfd %d"
,
return
log_warn
(
false
,
"Failed to send signal %d to pidfd %d"
,
haltsignal
,
pidfd
);
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. :)
*/
if
(
timeout
!=
0
)
{
ret
=
poll
(
&
pidfd_poll
,
1
,
timeout
);
if
(
ret
<
0
||
!
(
pidfd_poll
.
revents
&
POLLIN
))
return
false
;
TRACE
(
"Pidfd polling detected container exit"
);
}
}
else
{
}
else
{
killret
=
kill
(
pid
,
haltsignal
);
killret
=
kill
(
pid
,
haltsignal
);
if
(
killret
<
0
)
if
(
killret
<
0
)
...
@@ -2142,6 +2159,7 @@ static bool do_lxcapi_shutdown(struct lxc_container *c, int timeout)
...
@@ -2142,6 +2159,7 @@ static bool do_lxcapi_shutdown(struct lxc_container *c, int timeout)
TRACE
(
"Sent signal %d to pid %d"
,
haltsignal
,
pid
);
TRACE
(
"Sent signal %d to pid %d"
,
haltsignal
,
pid
);
}
}
}
if
(
timeout
==
0
)
if
(
timeout
==
0
)
return
true
;
return
true
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment