Commit 08cd374d authored by Kirill Tkhai's avatar Kirill Tkhai Committed by Pavel Emelyanov

unix: Link connected to peer sockets to its list

This is need for waiting a peer using task_st futex.

travis-ci: success for Rework file opening scheme to make it asynchronous (rev5)
Signed-off-by: 's avatarKirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent c6312764
...@@ -782,6 +782,8 @@ struct unix_sk_info { ...@@ -782,6 +782,8 @@ struct unix_sk_info {
unsigned flags; unsigned flags;
struct unix_sk_info *peer; struct unix_sk_info *peer;
struct file_desc d; 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 * Futex to signal when the socket is prepared. In particular, we
...@@ -1342,6 +1344,8 @@ static int collect_one_unixsk(void *o, ProtobufCMessage *base, struct cr_img *i) ...@@ -1342,6 +1344,8 @@ static int collect_one_unixsk(void *o, ProtobufCMessage *base, struct cr_img *i)
futex_init(&ui->prepared); futex_init(&ui->prepared);
ui->queuer = 0; ui->queuer = 0;
ui->peer = NULL; ui->peer = NULL;
INIT_LIST_HEAD(&ui->connected);
INIT_LIST_HEAD(&ui->node);
ui->flags = 0; ui->flags = 0;
pr_info(" `- Got %#x peer %#x (name %s dir %s)\n", pr_info(" `- Got %#x peer %#x (name %s dir %s)\n",
ui->ue->ino, ui->ue->peer, ui->ue->ino, ui->ue->peer,
...@@ -1359,6 +1363,12 @@ struct collect_image_info unix_sk_cinfo = { ...@@ -1359,6 +1363,12 @@ struct collect_image_info unix_sk_cinfo = {
.flags = COLLECT_SHARED, .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) static void interconnected_pair(struct unix_sk_info *ui, struct unix_sk_info *peer)
{ {
struct fdinfo_list_entry *fle, *fle_peer; struct fdinfo_list_entry *fle, *fle_peer;
...@@ -1397,7 +1407,7 @@ static int resolve_unix_peers(void *unused) ...@@ -1397,7 +1407,7 @@ static int resolve_unix_peers(void *unused)
return -1; return -1;
} }
ui->peer = peer; set_peer(ui, peer);
if (!peer->queuer) if (!peer->queuer)
peer->queuer = ui->ue->ino; peer->queuer = ui->ue->ino;
if (ui == peer) if (ui == peer)
...@@ -1406,7 +1416,7 @@ static int resolve_unix_peers(void *unused) ...@@ -1406,7 +1416,7 @@ static int resolve_unix_peers(void *unused)
if (peer->ue->peer != ui->ue->ino) if (peer->ue->peer != ui->ue->ino)
continue; continue;
peer->peer = ui; set_peer(peer, ui);
/* socketpair or interconnected sockets */ /* socketpair or interconnected sockets */
interconnected_pair(ui, peer); interconnected_pair(ui, peer);
......
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