[CRIU] [PATCH 3/4] files: Turn goto loop into while() one

Pavel Emelyanov xemul at virtuozzo.com
Tue Jan 24 23:54:28 PST 2017


Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/files.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/criu/files.c b/criu/files.c
index 5a3d700..1bed014 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -894,18 +894,21 @@ int recv_fd_from_peer(struct fdinfo_list_entry *fle)
 		return 0;
 
 	tsock = get_service_fd(TRANSPORT_FD_OFF);
-again:
-	if (ioctl(tsock, FIONREAD, &count) < 0) {
-		pr_perror("Can't do ioctl on transport sock: pid=%d\n", fle->pid);
-		return -1;
-	} else if (count == 0)
-		return 1;
 
-	ret = recv_fds(tsock, &fd, 1, (void *)&tmp, sizeof(struct fdinfo_list_entry *));
-	if (ret)
-		return -1;
+	while (1) {
+		if (ioctl(tsock, FIONREAD, &count) < 0) {
+			pr_perror("Can't do ioctl on transport sock: pid=%d\n", fle->pid);
+			return -1;
+		} else if (count == 0)
+			return 1;
+
+		ret = recv_fds(tsock, &fd, 1, (void *)&tmp, sizeof(struct fdinfo_list_entry *));
+		if (ret)
+			return -1;
+
+		if (tmp == fle)
+			break;
 
-	if (tmp != fle) {
 		pr_info("Further fle=%p, pid=%d\n", tmp, fle->pid);
 		if (!task_fle(current, tmp)) {
 			pr_err("Unexpected fle %p, pid=%d\n", tmp, current->pid.virt);
@@ -913,7 +916,6 @@ again:
 		}
 		if (plant_fd(tmp, fd))
 			return -1;
-		goto again;
 	}
 
 	if (plant_fd(fle, fd))
-- 
2.1.4



More information about the CRIU mailing list