[CRIU] [PATCH 23/28] files: Extract new_fle assignment from collect_fd() to separate func

Kirill Tkhai ktkhai at virtuozzo.com
Mon Jun 5 20:26:51 MSK 2017


The algorhythm of searching file master will be more complicated
in next patches. So, move current functionality in separate func.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/files.c |   23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/criu/files.c b/criu/files.c
index fbf809641..a46dcf330 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -714,9 +714,21 @@ static struct fdinfo_list_entry *alloc_fle(int pid, FdinfoEntry *fe)
 	return fle;
 }
 
+static void collect_desc_fle(struct fdinfo_list_entry *new_le, struct file_desc *fdesc)
+{
+	struct fdinfo_list_entry *le;
+
+	new_le->desc = fdesc;
+
+	list_for_each_entry(le, &fdesc->fd_info_head, desc_list)
+		if (pid_rst_prio(new_le->pid, le->pid))
+			break;
+	list_add_tail(&new_le->desc_list, &le->desc_list);
+}
+
 int collect_fd(int pid, FdinfoEntry *e, struct rst_info *rst_info)
 {
-	struct fdinfo_list_entry *le, *new_le;
+	struct fdinfo_list_entry *new_le;
 	struct file_desc *fdesc;
 
 	pr_info("Collect fdinfo pid=%d fd=%d id=%#x\n",
@@ -731,16 +743,9 @@ int collect_fd(int pid, FdinfoEntry *e, struct rst_info *rst_info)
 		pr_err("No file for fd %d id %#x\n", e->fd, e->id);
 		return -1;
 	}
-	new_le->desc = fdesc;
-
-	list_for_each_entry(le, &fdesc->fd_info_head, desc_list)
-		if (pid_rst_prio(new_le->pid, le->pid))
-			break;
-
+	collect_desc_fle(new_le, fdesc);
 	collect_task_fd(new_le, rst_info);
 
-	list_add_tail(&new_le->desc_list, &le->desc_list);
-
 	return 0;
 }
 



More information about the CRIU mailing list