Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/checkpoint-restore/criu.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@virtuozzo.com>2017-02-14 19:55:58 +0300
committerPavel Emelyanov <xemul@virtuozzo.com>2017-03-06 11:38:36 +0300
commite7523317e058a65d1c667fe8f75c8864739b20e8 (patch)
tree285ed5757fd58150b7d75f50f413b5381dddd383
parent3200fa8f934d87de153d9e931f11607fc689b684 (diff)
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: Pavel Emelyanov <xemul@virtuozzo.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
-rw-r--r--criu/sk-unix.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/criu/sk-unix.c b/criu/sk-unix.c
index e13f182c1..70d0946b1 100644
--- a/criu/sk-unix.c
+++ b/criu/sk-unix.c
@@ -919,25 +919,17 @@ static int post_open_unix_sk(struct file_desc *d, int fd)
int cwd_fd = -1, root_fd = -1;
ui = container_of(d, struct unix_sk_info, d);
- if (ui->flags & (USK_PAIR_MASTER | USK_PAIR_SLAVE))
- return 0;
+ BUG_ON((ui->flags & (USK_PAIR_MASTER | USK_PAIR_SLAVE)) ||
+ (ui->ue->uflags & (USK_CALLBACK | USK_INHERIT)));
peer = ui->peer;
-
- if (peer == NULL)
- return 0;
-
- if (ui->ue->uflags & USK_CALLBACK)
- return 0;
+ BUG_ON(peer == NULL);
/* Skip external sockets */
if (!list_empty(&peer->d.fd_info_head))
if (peer_is_not_prepared(peer))
return 1;
- if (ui->ue->uflags & USK_INHERIT)
- return 0;
-
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
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)
ui->listen = 1;
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:
if (rst_file_params(sk, ui->ue->fown, ui->ue->flags))
return -1;
@@ -1298,8 +1301,11 @@ out:
if (restore_socket_opts(sk, ui->ue->opts))
return -1;
+ if (shutdown_unix_sk(sk, ui))
+ return -1;
+
*new_fd = sk;
- return 1;
+ return 0;
}
static int open_unix_sk(struct file_desc *d, int *new_fd)