[CRIU] [PATCH RFC 09/12] files: Receive real fd numbers using recv_fd_from_peer()
Kirill Tkhai
ktkhai at virtuozzo.com
Fri Oct 28 05:53:53 PDT 2016
Move reopen_fd_as() to this function.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/files.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/criu/files.c b/criu/files.c
index 7683b1c..5f3388a 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -936,7 +936,10 @@ int recv_fd_from_peer(struct fdinfo_list_entry *fle)
BUG_ON(fle->received);
fle->received = true;
- return fd;
+ if (reopen_fd_as(fle->fe->fd, fd) < 0)
+ return -1;
+
+ return fle->fe->fd;
}
int send_fd_to_peer(int fd, struct fdinfo_list_entry *fle)
@@ -1061,7 +1064,7 @@ static int open_fd(int pid, struct fdinfo_list_entry *fle)
static int receive_fd(int pid, struct fdinfo_list_entry *fle)
{
- int tmp;
+ int fd;
struct fdinfo_list_entry *flem;
flem = file_master(fle->desc);
@@ -1070,14 +1073,13 @@ static int receive_fd(int pid, struct fdinfo_list_entry *fle)
pr_info("\tReceive fd for %d\n", fle->fe->fd);
- tmp = recv_fd_from_peer(fle);
- if (tmp < 0) {
- pr_err("Can't get fd %d\n", tmp);
+ fd = recv_fd_from_peer(fle);
+ if (fd < 0) {
+ pr_err("Can't get fd=%d, pid=%d\n", fle->fe->fd, fle->pid);
return -1;
}
- if (reopen_fd_as(fle->fe->fd, tmp) < 0)
- return -1;
+ BUG_ON(fd != fle->fe->fd);
if (fcntl(fle->fe->fd, F_SETFD, fle->fe->flags) == -1) {
pr_perror("Unable to set file descriptor flags");
More information about the CRIU
mailing list