Commit 98c8e44f authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

pipe: don't create a tranport descriptor for inhereted pipes

Otherwise we can get an error like this:
1: \t\tCreate transport fd /crtools-fd-1-5
...
1: Found id pipe:[122747] (fd 8) in inherit fd list
1: File pipe:[122747] will be restored from fd 9 duped from inherit

1: Error (util.c:131): fd 5 already in use (called at files.c:872)
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 2045ef18
......@@ -1394,6 +1394,9 @@ bool inherited_fd(struct file_desc *d, int *fd_p)
if (i_fd < 0)
return false;
if (fd_p == NULL)
return true;
*fd_p = dup(i_fd);
if (*fd_p < 0)
pr_perror("Inherit fd DUP failed");
......
......@@ -393,18 +393,22 @@ static int collect_one_pipe(void *o, ProtobufCMessage *base)
pr_info("Collected pipe entry ID %#x PIPE ID %#x\n",
pi->pe->id, pi->pe->pipe_id);
list_for_each_entry(tmp, &pipes, list)
if (pi->pe->pipe_id == tmp->pe->pipe_id)
break;
if (file_desc_add(&pi->d, pi->pe->id, &pipe_desc_ops))
return -1;
if (&tmp->list == &pipes)
INIT_LIST_HEAD(&pi->pipe_list);
else
list_add(&pi->pipe_list, &tmp->pipe_list);
INIT_LIST_HEAD(&pi->pipe_list);
if (!inherited_fd(&pi->d, NULL)) {
list_for_each_entry(tmp, &pipes, list)
if (pi->pe->pipe_id == tmp->pe->pipe_id)
break;
if (&tmp->list != &pipes)
list_add(&pi->pipe_list, &tmp->pipe_list);
}
list_add_tail(&pi->list, &pipes);
return file_desc_add(&pi->d, pi->pe->id, &pipe_desc_ops);
return 0;
}
struct collect_image_info pipe_cinfo = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment