[CRIU] [PATCH] fix data loss when dumping semi-closed unix stream connection.

Ruslan Kuprieiev kupruser at gmail.com
Mon Aug 26 14:49:42 EDT 2013


Hi!

This patch fixes running into loop and data loss, when dumping 
semi-closed unix stream connection.


-------------- next part --------------
Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>

diff --git a/sk-queue.c b/sk-queue.c
index 3624258..5896e97 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");
diff --git a/sk-unix.c b/sk-unix.c
index 177bb8b..47aff69 100644
--- a/sk-unix.c
+++ b/sk-unix.c
@@ -737,6 +737,11 @@ static int open_unixsk_standalone(struct unix_sk_info *ui)
 			return -1;
 		}
 
+		/*
+		 * Restore queue at the one end,
+		 * before closing the second one.
+		 */
+		restore_sk_queue(sks[1], ui->ue->id);
 		close(sks[1]);
 		sk = sks[0];
 	} else {


More information about the CRIU mailing list