[CRIU] [PATCH 2/5] pipe: add ability to restore both ends of inhereted pipes

Andrey Vagin avagin at openvz.org
Thu Jul 2 02:47:08 PDT 2015


When we restore an inhereted pipe, we have only one end and we
don't know whether it's write or read one. So we need to call
reopen_pipe each time.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 pipes.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/pipes.c b/pipes.c
index 62f550c..4631231 100644
--- a/pipes.c
+++ b/pipes.c
@@ -314,11 +314,15 @@ static int open_pipe(struct file_desc *d)
 	int pfd[2];
 	int sock;
 
-	if (inherited_fd(d, &tmp))
-		return tmp;
-
 	pi = container_of(d, struct pipe_info, d);
 	pr_info("\t\tCreating pipe pipe_id=%#x id=%#x\n", pi->pe->pipe_id, pi->pe->id);
+	if (inherited_fd(d, &tmp)) {
+		if (tmp < 0)
+			return tmp;
+
+		pi->reopen = 1;
+		goto out;
+	}
 
 	if (!pi->create)
 		return recv_pipe_fd(pi);
@@ -357,6 +361,7 @@ static int open_pipe(struct file_desc *d)
 	close(pfd[!(pi->pe->flags & O_WRONLY)]);
 	tmp = pfd[pi->pe->flags & O_WRONLY];
 
+out:
 	if (pi->reopen)
 		tmp = reopen_pipe(tmp, pi->pe->flags);
 
-- 
2.1.0



More information about the CRIU mailing list