[CRIU] dump_sk_queue sk queue dumping done if ret == 0

Ruslan Kuprieiev kupruser at gmail.com
Sat Aug 24 18:29:04 EDT 2013


Hi all!

dump_sk_queue() assumes end  of queue if EAGAIN is returned, but kernel 
in net/unix/af_unix.c:unix_stream_recvmsg() returns 0, if second end of 
socket is closed.
This cause running into loop and writing zeros to img, when dumping pair 
of sockets, where data is stored and one side if closed.

Signed-off-by: Ruslan Kuprieiev kupruser at gmail.com


-------------- next part --------------
Signed-off-by: Ruslan Kuprieiev kupruser at gmail.com
diff --git a/sk-queue.c b/sk-queue.c
index 3624258..f1bcebf 100644
--- a/sk-queue.c
+++ b/sk-queue.c
@@ -127,7 +127,13 @@ int dump_sk_queue(int sock_fd, int sock_id)
 		};
 
 		ret = pe.length = recvmsg(sock_fd, &msg, MSG_DONTWAIT | MSG_PEEK);
-		if (ret < 0) {
+		if (!ret)
+			/*
+			 * It means, that peer has performed an orderly
+			 * shutdown, so we're done.
+			 */
+			break;
+		else if (ret < 0) {
 			if (errno == EAGAIN)
 				break; /* we're done */
 			pr_perror("recvmsg fail: error");


More information about the CRIU mailing list