[Devel] [PATCH criu] page-xfer: handle a case when splice returns zero

Dmitry Safonov dsafonov at virtuozzo.com
Thu Jul 20 18:48:38 MSK 2017


On 07/20/2017 05:33 AM, Andrei Vagin wrote:
> From: Andrei Vagin <avagin at virtuozzo.com>
> 
> A return value of 0 means end of input, so we need to
> stop reading from this descriptor.
> 
> https://jira.sw.ru/browse/PSBM-68732
> 
> Cc: Dmitry Safonov <dsafonov at virtuozzo.com>
> Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>

Applied to vz-criu, released in criu-3.0.0.24-1.vz7

> ---
>   criu/page-xfer.c | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
> 
> diff --git a/criu/page-xfer.c b/criu/page-xfer.c
> index 6e64f2d..947487e 100644
> --- a/criu/page-xfer.c
> +++ b/criu/page-xfer.c
> @@ -106,6 +106,11 @@ static int write_pages_to_server(struct page_xfer *xfer,
>   			return -1;
>   		}
>   
> +		if (ret == 0) {
> +			pr_err("A pipe was closed unexpectedly\n");
> +			return -1;
> +		}
> +
>   		pr_debug("\tSpliced: %lu bytes sent\n", (unsigned long)ret);
>   		left -= ret;
>   	}
> @@ -186,6 +191,10 @@ static int write_pages_loc(struct page_xfer *xfer,
>   			pr_perror("Unable to spice data");
>   			return -1;
>   		}
> +		if (ret == 0) {
> +			pr_err("A pipe was closed unexpectedly");
> +			return -1;
> +		}
>   		curr += ret;
>   		if (curr == len)
>   			break;
> @@ -581,6 +590,10 @@ static int page_server_add(int sk, struct page_server_iov *pi)
>   			pr_perror("Can't read from socket");
>   			return -1;
>   		}
> +		if (chunk == 0) {
> +			pr_err("The socket was closed unexpectedly\n");
> +			return -1;
> +		}
>   
>   		if (lxfer->write_pages(lxfer, cxfer.p[0], chunk))
>   			return -1;
> 


-- 
              Dmitry


More information about the Devel mailing list