[CRIU] [PATCH v5 05/33] files: Add fle_init() for initialization new fdinfo_list_entry

Kirill Tkhai ktkhai at virtuozzo.com
Mon Dec 26 06:25:24 PST 2016


No functional changes

v3: Also do real_pid futex initialization

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/autofs.c        |    4 +---
 criu/files.c         |    4 +---
 criu/include/files.h |    7 +++++++
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/criu/autofs.c b/criu/autofs.c
index 151980d63..d9f518fdd 100644
--- a/criu/autofs.c
+++ b/criu/autofs.c
@@ -873,9 +873,7 @@ static int autofs_create_fle(struct pstree_item *task, FdinfoEntry *fe,
 		return -1;
 	le = (void *)ALIGN((long)le, sizeof(int));
 
-	futex_init(&le->real_pid);
-	le->pid = task->pid.virt;
-	le->fe = fe;
+	fle_init(le, task->pid.virt, fe);
 
 	collect_gen_fd(le, rst_info);
 
diff --git a/criu/files.c b/criu/files.c
index f0529bb5d..7ccf235d7 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -694,9 +694,7 @@ static int collect_fd(int pid, FdinfoEntry *e, struct rst_info *rst_info)
 	if (!new_le)
 		return -1;
 
-	futex_init(&new_le->real_pid);
-	new_le->pid = pid;
-	new_le->fe = e;
+	fle_init(new_le, pid, e);
 
 	fdesc = find_file_desc(e);
 	if (fdesc == NULL) {
diff --git a/criu/include/files.h b/criu/include/files.h
index d2882d471..1275a2be1 100644
--- a/criu/include/files.h
+++ b/criu/include/files.h
@@ -74,6 +74,13 @@ struct fdinfo_list_entry {
 	FdinfoEntry		*fe;
 };
 
+static inline void fle_init(struct fdinfo_list_entry *fle, int pid, FdinfoEntry *fe)
+{
+	futex_init(&fle->real_pid);
+	fle->pid = pid;
+	fle->fe = fe;
+}
+
 /* reports whether fd_a takes prio over fd_b */
 static inline int fdinfo_rst_prio(struct fdinfo_list_entry *fd_a, struct fdinfo_list_entry *fd_b)
 {



More information about the CRIU mailing list