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

Andrei Vagin avagin at openvz.org
Thu Jul 20 05:33:13 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.

https://jira.sw.ru/browse/PSBM-68732

Cc: Dmitry Safonov <dsafonov at virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 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;
-- 
2.9.4



More information about the Devel mailing list