[CRIU] [PATCH RFC v2 02/14] files: Wait transport_fd before sending a fd to peer
Kirill Tkhai
ktkhai at virtuozzo.com
Fri Oct 28 14:05:56 PDT 2016
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/files.c | 2 ++
criu/include/pstree.h | 2 ++
criu/pstree.c | 1 +
3 files changed, 5 insertions(+)
diff --git a/criu/files.c b/criu/files.c
index e869614..4d999b0 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -964,6 +964,7 @@ int send_fd_to_peer(int fd, struct fdinfo_list_entry *fle, int sock)
pr_info("\t\tWait fdinfo pid=%d fd=%d\n", fle->pid, fle->fe->fd);
futex_wait_while(&fle->real_pid, 0);
+ futex_wait_while(&pstree_item_by_virt(fle->pid)->transport_fd, 0);
transport_name_gen(&saddr, &len,
futex_get(&fle->real_pid), fle->fe->fd);
pr_info("\t\tSend fd %d to %s\n", fd, saddr.sun_path + 1);
@@ -1691,6 +1692,7 @@ static int open_transport_socket(pid_t pid)
return -1;
}
close(sock);
+ futex_set_and_wake(¤t->transport_fd, 1);
return 0;
}
diff --git a/criu/include/pstree.h b/criu/include/pstree.h
index 5768b64..18af224 100644
--- a/criu/include/pstree.h
+++ b/criu/include/pstree.h
@@ -4,6 +4,7 @@
#include "common/list.h"
#include "pid.h"
#include "images/core.pb-c.h"
+#include "lock.h"
/*
* That's the init process which usually inherit
@@ -24,6 +25,7 @@ struct pstree_item {
struct pid *threads; /* array of threads */
CoreEntry **core;
TaskKobjIdsEntry *ids;
+ futex_t transport_fd;
};
struct pstree_item *current;
diff --git a/criu/pstree.c b/criu/pstree.c
index ec1f7ee..3b2fb3d 100644
--- a/criu/pstree.c
+++ b/criu/pstree.c
@@ -216,6 +216,7 @@ struct pstree_item *__alloc_pstree_item(bool rst)
item->pid.virt = -1;
item->pid.real = -1;
item->born_sid = -1;
+ futex_init(&item->transport_fd);
return item;
}
More information about the CRIU
mailing list