[CRIU] [PATCH v4 03/19] files: Do not close PROC_PID_FD_OFF sfd in prepare_fds()

Kirill Tkhai ktkhai at virtuozzo.com
Wed Jan 10 17:00:48 MSK 2018


Here we need to close proc self fd only, as it's not
a service fd, and it can occupy real task fd number.
Closing of PROC_PID_FD_OFF is useless action here,
because it's already occupy a service fd number.

So, we skip this excess syscall, and leave PROC_PID_FD_OFF
open.

v4: New

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/files.c             |    2 +-
 criu/include/servicefd.h |    1 +
 criu/util.c              |    2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/criu/files.c b/criu/files.c
index 9d1663d78..d1a961d58 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -1297,7 +1297,7 @@ int prepare_fds(struct pstree_item *me)
 	 * set than its parent
 	 */
 	close_service_fd(CGROUP_YARD);
-	close_pid_proc(); /* flush any proc cached fds we may have */
+	set_proc_self_fd(-1); /* flush any proc cached fds we may have */
 
 	if (rsti(me)->fdt) {
 		struct fdt *fdt = rsti(me)->fdt;
diff --git a/criu/include/servicefd.h b/criu/include/servicefd.h
index 0c4d6c102..6266b5324 100644
--- a/criu/include/servicefd.h
+++ b/criu/include/servicefd.h
@@ -28,6 +28,7 @@ enum sfd_type {
 
 struct pstree_item;
 
+extern void set_proc_self_fd(int fd);
 extern int clone_service_fd(int id);
 extern int init_service_fd(void);
 extern int get_service_fd(enum sfd_type type);
diff --git a/criu/util.c b/criu/util.c
index 386c755a6..88f4914a0 100644
--- a/criu/util.c
+++ b/criu/util.c
@@ -296,7 +296,7 @@ static pid_t open_proc_pid = PROC_NONE;
 static pid_t open_proc_self_pid;
 static int open_proc_self_fd = -1;
 
-static inline void set_proc_self_fd(int fd)
+void set_proc_self_fd(int fd)
 {
 	if (open_proc_self_fd >= 0)
 		close(open_proc_self_fd);



More information about the CRIU mailing list