[CRIU] [PATCH v2 18/28] unix: Link connected to peer sockets to its list
Kirill Tkhai
ktkhai at virtuozzo.com
Wed Nov 30 08:32:22 PST 2016
This is need for waiting a peer using task_st futex.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/sk-unix.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/criu/sk-unix.c b/criu/sk-unix.c
index 4b6111d..0f0ba61 100644
--- a/criu/sk-unix.c
+++ b/criu/sk-unix.c
@@ -781,6 +781,8 @@ struct unix_sk_info {
unsigned flags;
struct unix_sk_info *peer;
struct file_desc d;
+ struct list_head connected; /* List of sockets, connected to me */
+ struct list_head node; /* To link in peer's connected list */
/*
* Futex to signal when the socket is prepared. In particular, we
@@ -1341,6 +1343,8 @@ static int collect_one_unixsk(void *o, ProtobufCMessage *base, struct cr_img *i)
futex_init(&ui->prepared);
ui->queuer = 0;
ui->peer = NULL;
+ INIT_LIST_HEAD(&ui->connected);
+ INIT_LIST_HEAD(&ui->node);
ui->flags = 0;
pr_info(" `- Got %#x peer %#x (name %s dir %s)\n",
ui->ue->ino, ui->ue->peer,
@@ -1358,6 +1362,12 @@ struct collect_image_info unix_sk_cinfo = {
.flags = COLLECT_SHARED,
};
+static void set_peer(struct unix_sk_info *ui, struct unix_sk_info *peer)
+{
+ ui->peer = peer;
+ list_add(&ui->node, &peer->connected);
+}
+
static void interconnected_pair(struct unix_sk_info *ui, struct unix_sk_info *peer)
{
struct fdinfo_list_entry *fle, *fle_peer;
@@ -1396,7 +1406,7 @@ static int resolve_unix_peers(void *unused)
return -1;
}
- ui->peer = peer;
+ set_peer(ui, peer);
if (!peer->queuer)
peer->queuer = ui->ue->ino;
if (ui == peer)
@@ -1405,7 +1415,7 @@ static int resolve_unix_peers(void *unused)
if (peer->ue->peer != ui->ue->ino)
continue;
- peer->peer = ui;
+ set_peer(peer, ui);
/* socketpair or interconnected sockets */
interconnected_pair(ui, peer);
More information about the CRIU
mailing list