mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-08-02 23:03:09 +00:00
pipe: restore pipe size even if a pipe is empty
Without this patch, pipe size is restored only if a pipe has queued data. Reported-by: Mr Jenkins Signed-off-by: Andrei Vagin <avagin@gmail.com>
This commit is contained in:
parent
fa705e418b
commit
2b376168ef
1 changed files with 12 additions and 16 deletions
28
criu/pipes.c
28
criu/pipes.c
|
|
@ -160,24 +160,24 @@ int restore_pipe_data(int img_type, int pfd, u32 id, struct pipe_data_rst **hash
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (!pd->pde->bytes)
|
||||
goto out;
|
||||
|
||||
if (!pd->data) {
|
||||
pr_err("Double data restore occurred on %#x\n", id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pd->pde->has_size) {
|
||||
pr_info("Restoring size %#x for %#x\n",
|
||||
pd->pde->size, pd->pde->pipe_id);
|
||||
ret = fcntl(pfd, F_SETPIPE_SZ, pd->pde->size);
|
||||
if (ret < 0) {
|
||||
pr_perror("Can't restore pipe size");
|
||||
goto err;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pd->pde->bytes)
|
||||
return 0;
|
||||
|
||||
if (!pd->data) {
|
||||
pr_err("Double data restore occurred on %#x\n", id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
iov.iov_base = pd->data;
|
||||
iov.iov_len = pd->pde->bytes;
|
||||
|
||||
|
|
@ -185,14 +185,13 @@ int restore_pipe_data(int img_type, int pfd, u32 id, struct pipe_data_rst **hash
|
|||
ret = vmsplice(pfd, &iov, 1, SPLICE_F_GIFT | SPLICE_F_NONBLOCK);
|
||||
if (ret < 0) {
|
||||
pr_perror("%#x: Error splicing data", id);
|
||||
goto err;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ret == 0 || ret > iov.iov_len /* sanity */) {
|
||||
pr_err("%#x: Wanted to restore %zu bytes, but got %d\n", id,
|
||||
iov.iov_len, ret);
|
||||
ret = -1;
|
||||
goto err;
|
||||
return -1;
|
||||
}
|
||||
|
||||
iov.iov_base += ret;
|
||||
|
|
@ -211,10 +210,7 @@ int restore_pipe_data(int img_type, int pfd, u32 id, struct pipe_data_rst **hash
|
|||
|
||||
munmap(pd->data, pd->pde->bytes);
|
||||
pd->data = NULL;
|
||||
out:
|
||||
ret = 0;
|
||||
err:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int userns_reopen(void *_arg, int fd, pid_t pid)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue