Commit e7523317 authored by Pavel Emelyanov's avatar Pavel Emelyanov

unix: Fix tail processing for peer-less sockets

We should only get to the post-open stage for standalone
sockets with peers. All the others return 0 from ->open
which means "restore is over".

This change avoids double calling or rst_file_params and
restore_socket_opts for those ones.
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 3200fa8f
...@@ -919,25 +919,17 @@ static int post_open_unix_sk(struct file_desc *d, int fd) ...@@ -919,25 +919,17 @@ static int post_open_unix_sk(struct file_desc *d, int fd)
int cwd_fd = -1, root_fd = -1; int cwd_fd = -1, root_fd = -1;
ui = container_of(d, struct unix_sk_info, d); ui = container_of(d, struct unix_sk_info, d);
if (ui->flags & (USK_PAIR_MASTER | USK_PAIR_SLAVE)) BUG_ON((ui->flags & (USK_PAIR_MASTER | USK_PAIR_SLAVE)) ||
return 0; (ui->ue->uflags & (USK_CALLBACK | USK_INHERIT)));
peer = ui->peer; peer = ui->peer;
BUG_ON(peer == NULL);
if (peer == NULL)
return 0;
if (ui->ue->uflags & USK_CALLBACK)
return 0;
/* Skip external sockets */ /* Skip external sockets */
if (!list_empty(&peer->d.fd_info_head)) if (!list_empty(&peer->d.fd_info_head))
if (peer_is_not_prepared(peer)) if (peer_is_not_prepared(peer))
return 1; return 1;
if (ui->ue->uflags & USK_INHERIT)
return 0;
memset(&addr, 0, sizeof(addr)); memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX; addr.sun_family = AF_UNIX;
memcpy(&addr.sun_path, peer->name, peer->ue->name.len); memcpy(&addr.sun_path, peer->name, peer->ue->name.len);
...@@ -1291,6 +1283,17 @@ static int open_unixsk_standalone(struct unix_sk_info *ui, int *new_fd) ...@@ -1291,6 +1283,17 @@ static int open_unixsk_standalone(struct unix_sk_info *ui, int *new_fd)
ui->listen = 1; ui->listen = 1;
wake_connected_sockets(ui); wake_connected_sockets(ui);
} }
if (ui->peer) {
/*
* We need to connect() to the peer, but the
* guy might have not bind()-ed himself, so
* let's postpone this.
*/
*new_fd = sk;
return 1;
}
out: out:
if (rst_file_params(sk, ui->ue->fown, ui->ue->flags)) if (rst_file_params(sk, ui->ue->fown, ui->ue->flags))
return -1; return -1;
...@@ -1298,8 +1301,11 @@ out: ...@@ -1298,8 +1301,11 @@ out:
if (restore_socket_opts(sk, ui->ue->opts)) if (restore_socket_opts(sk, ui->ue->opts))
return -1; return -1;
if (shutdown_unix_sk(sk, ui))
return -1;
*new_fd = sk; *new_fd = sk;
return 1; return 0;
} }
static int open_unix_sk(struct file_desc *d, int *new_fd) static int open_unix_sk(struct file_desc *d, int *new_fd)
......
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