2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-29 13:28:27 +00:00

unix: Simplify unix post-open callback

The fd we want to work on is the 2nd argument, no need
in calculating it out of file_desc.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Pavel Emelyanov 2012-10-24 22:08:46 +04:00
parent 2f5d7098b8
commit 080282df7c

View File

@ -503,9 +503,8 @@ static int shutdown_unix_sk(int sk, struct unix_sk_info *ui)
static int post_open_unix_sk(struct file_desc *d, int fd) static int post_open_unix_sk(struct file_desc *d, int fd)
{ {
struct unix_sk_info *ui; struct unix_sk_info *ui;
struct unix_sk_info *peer; struct unix_sk_info *peer;
struct fdinfo_list_entry *fle; struct sockaddr_un addr;
struct sockaddr_un addr;
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)) if (ui->flags & (USK_PAIR_MASTER | USK_PAIR_SLAVE))
@ -518,8 +517,6 @@ static int post_open_unix_sk(struct file_desc *d, int fd)
pr_info("\tConnect %#x to %#x\n", ui->ue->ino, peer->ue->ino); pr_info("\tConnect %#x to %#x\n", ui->ue->ino, peer->ue->ino);
fle = file_master(&ui->d);
/* Skip external sockets */ /* Skip external sockets */
if (!list_empty(&peer->d.fd_info_head)) if (!list_empty(&peer->d.fd_info_head))
futex_wait_while(&peer->bound, 0); futex_wait_while(&peer->bound, 0);
@ -528,23 +525,23 @@ static int post_open_unix_sk(struct file_desc *d, int fd)
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);
if (connect(fle->fe->fd, (struct sockaddr *)&addr, if (connect(fd, (struct sockaddr *)&addr,
sizeof(addr.sun_family) + sizeof(addr.sun_family) +
peer->ue->name.len) < 0) { peer->ue->name.len) < 0) {
pr_perror("Can't connect %#x socket", ui->ue->ino); pr_perror("Can't connect %#x socket", ui->ue->ino);
return -1; return -1;
} }
if (restore_sk_queue(fle->fe->fd, peer->ue->id)) if (restore_sk_queue(fd, peer->ue->id))
return -1; return -1;
if (rst_file_params(fle->fe->fd, ui->ue->fown, ui->ue->flags)) if (rst_file_params(fd, ui->ue->fown, ui->ue->flags))
return -1; return -1;
if (restore_socket_opts(fle->fe->fd, ui->ue->opts)) if (restore_socket_opts(fd, ui->ue->opts))
return -1; return -1;
if (shutdown_unix_sk(fle->fe->fd, ui)) if (shutdown_unix_sk(fd, ui))
return -1; return -1;
return 0; return 0;