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

Andrei Vagin avagin at openvz.org
Thu Jul 20 05:31:43 MSK 2017


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.

Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 criu/page-xfer.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/criu/page-xfer.c b/criu/page-xfer.c
index 49693bb..56b7c91 100644
--- a/criu/page-xfer.c
+++ b/criu/page-xfer.c
@@ -182,6 +182,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;
@@ -652,6 +656,10 @@ static int page_server_add(int sk, struct page_server_iov *pi, u32 flags)
 			pr_perror("Can't read from socket");
 			return -1;
 		}
+		if (chunk == 0) {
+			pr_err("A socket was closed unexpectedly");
+			return -1;
+		}
 
 		if (lxfer->write_pages(lxfer, cxfer.p[0], chunk))
 			return -1;
-- 
2.9.4



More information about the CRIU mailing list