Commit 83f1f7e5 authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

rst: only restore dgram socket queue once

In the case where there were multiple clients for a dgram socket, we were
restoring the queue for each client. Instead, we should pick one client and
she should restore the queue while the rest skip it.
Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 03c2a0a6
......@@ -638,6 +638,13 @@ struct unix_sk_info {
* after listen() if the socket is in TCP_LISTEN.
*/
futex_t prepared;
/*
* For DGRAM sockets with queues, we should only restore the queue
* once although it may be open by more than one tid. This is the peer
* that should do the queueing.
*/
u32 queuer;
};
#define USK_PAIR_MASTER 0x1
......@@ -708,7 +715,7 @@ static int post_open_unix_sk(struct file_desc *d, int fd)
return -1;
}
if (restore_sk_queue(fd, peer->ue->id))
if (peer->queuer == ui->ue->ino && restore_sk_queue(fd, peer->ue->id))
return -1;
if (rst_file_params(fd, ui->ue->fown, ui->ue->flags))
......@@ -1021,6 +1028,7 @@ static int collect_one_unixsk(void *o, ProtobufCMessage *base)
ui->name = NULL;
futex_init(&ui->prepared);
ui->queuer = 0;
ui->peer = NULL;
ui->flags = 0;
pr_info(" `- Got %#x peer %#x (name %s)\n",
......@@ -1063,6 +1071,8 @@ int resolve_unix_peers(void)
}
ui->peer = peer;
if (!ui->queuer)
ui->queuer = ui->ue->ino;
if (ui == peer)
/* socket connected to self %) */
continue;
......
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