2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-22 18:07:57 +00:00

restore: Add comment about closing pipes descriptors

Also a few style nitpicks.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
Cyrill Gorcunov 2011-09-27 20:23:26 +04:00
parent eb457b71fb
commit af1dfdda5e

View File

@ -821,8 +821,8 @@ static int execute_image(int pid)
static int create_pipe(int pid, struct pipe_entry *e, struct pipe_info *pi, int pipes_fd)
{
int pfd[2], tmp;
unsigned long time = 1000;
int pfd[2], tmp;
pr_info("\t%d: Creating pipe %x\n", pid, e->pipeid);
@ -849,7 +849,7 @@ static int create_pipe(int pid, struct pipe_entry *e, struct pipe_info *pi, int
pi->real_pid = getpid();
pr_info("\t%d: Done, waiting for others on %d pid with r:%d w:%d\n",
pid, pi->real_pid, pfd[0], pfd[1]);
pid, pi->real_pid, pi->read_fd, pi->write_fd);
while (1) {
if (pi->users == 1) /* only I left */
@ -862,6 +862,12 @@ static int create_pipe(int pid, struct pipe_entry *e, struct pipe_info *pi, int
usleep(time);
}
/*
* At this point everyone who needed our pipe descriptors
* should have them attched so we're safe to close pipe
* descriptors here.
*/
pr_info("\t%d: All is ok - reopening pipe for %d\n", pid, e->fd);
if (e->flags & O_WRONLY) {
close_safe(&pi->read_fd);
@ -892,6 +898,11 @@ static int attach_pipe(int pid, struct pipe_entry *e, struct pipe_info *pi)
else
tmp = pi->read_fd;
if (tmp == -1) {
pr_panic("Attaching closed pipe\n");
return 1;
}
sprintf(path, "/proc/%d/fd/%d", pi->real_pid, tmp);
pr_info("\t%d: Attaching pipe %s\n", pid, path);