[CRIU] [PATCH RFC 16/30] files: Kill fd_open_state::receive_fd stage

Kirill Tkhai ktkhai at virtuozzo.com
Tue Nov 1 07:32:58 PDT 2016


Since "receive" stage is used only for slave fds
and nobody depends on slave fds receiving is finished,
we may move it functionality in "post_open" stage.
This just makes slave fds to be received a little bit later.

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

diff --git a/criu/files.c b/criu/files.c
index 9a7b645..7de9f61 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -865,7 +865,6 @@ static int post_open_fd(int pid, struct fdinfo_list_entry *fle);
 
 static struct fd_open_state states[] = {
 	{ "create",		open_fd,	},
-	{ "receive",		receive_fd,	},
 	{ "post_create",	post_open_fd,	},
 };
 
@@ -973,15 +972,17 @@ static int post_open_fd(int pid, struct fdinfo_list_entry *fle)
 {
 	struct file_desc *d = fle->desc;
 
-	if (!d->ops->post_open)
-		return 0;
-
-	if (is_service_fd(fle->fe->fd, CTL_TTY_OFF))
-		return d->ops->post_open(d, fle->fe->fd);
+	if (fle != file_master(d)) {
+		if (receive_fd(pid, fle) < 0) {
+			pr_err("Can't receive\n");
+			return -1;
+		}
+		if (!is_service_fd(fle->fe->fd, CTL_TTY_OFF))
+			return 0;
+	}
 
-	if (fle != file_master(d))
+	if (!d->ops->post_open)
 		return 0;
-
 	return d->ops->post_open(d, fle->fe->fd);
 }
 
@@ -1036,11 +1037,6 @@ static int open_fd(int pid, struct fdinfo_list_entry *fle)
 static int receive_fd(int pid, struct fdinfo_list_entry *fle)
 {
 	int fd;
-	struct fdinfo_list_entry *flem;
-
-	flem = file_master(fle->desc);
-	if (flem->pid == pid)
-		return 0;
 
 	pr_info("\tReceive fd for %d\n", fle->fe->fd);
 



More information about the CRIU mailing list