[CRIU] [PATCH 1/3] pid_ns: Extract functionality of exit of pid_ns helper in function
Kirill Tkhai
ktkhai at virtuozzo.com
Fri Jun 30 20:02:59 MSK 2017
This functionality will be moved in criu task in next patches,
the patch is a preparation.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/include/namespaces.h | 1 +
criu/namespaces.c | 29 +++++++++++++++++++----------
2 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/criu/include/namespaces.h b/criu/include/namespaces.h
index 3cfa9a9bf..7f472def7 100644
--- a/criu/include/namespaces.h
+++ b/criu/include/namespaces.h
@@ -278,6 +278,7 @@ static inline int pid_ns_root_off(void)
extern int reserve_pid_ns_helpers(void);
extern int create_pid_ns_helper(struct ns_id *ns);
extern int destroy_pid_ns_helpers(void);
+extern struct ns_id *handle_pid_ns_helper_exit(pid_t real_pid);
extern int request_set_next_pid(int pid_ns_id, pid_t pid, int sk);
#endif /* __CR_NS_H__ */
diff --git a/criu/namespaces.c b/criu/namespaces.c
index 15de9c515..c44480b37 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -1579,27 +1579,36 @@ static void unsc_msg_pid_fd(struct unsc_msg *um, pid_t *pid, int *fd)
}
}
+struct ns_id *handle_pid_ns_helper_exit(pid_t real_pid)
+{
+ struct ns_id *ns;
+ struct pid *pid;
+
+ for (ns = ns_ids; ns; ns = ns->next) {
+ if (ns->nd != &pid_ns_desc)
+ continue;
+ pid = __pstree_pid_by_virt(ns, ns->ns_pid);
+ if (pid->real == real_pid) {
+ pid->real = -1;
+ break;
+ }
+ }
+
+ return ns;
+}
+
static void usernsd_handler(int signal, siginfo_t *siginfo, void *data)
{
pid_t pid = siginfo->si_pid;
struct ns_id *ns;
- struct pid *tpid;
int status;
while (pid) {
pid = waitpid(-1, &status, WNOHANG);
if (pid <= 0)
return;
- for (ns = ns_ids; ns; ns = ns->next) {
- if (ns->nd != &pid_ns_desc)
- continue;
- tpid = __pstree_pid_by_virt(ns, ns->ns_pid);
- if (tpid->real == pid) {
- tpid->real = -1;
- break;
- }
- }
+ ns = handle_pid_ns_helper_exit(pid);
if (!ns)
pr_err("Spurious pid ns helper: pid=%d\n", pid);
More information about the CRIU
mailing list