[CRIU] [PATCH 1/2] restorer: Change endless loop to sys_exit in case of error

Cyrill Gorcunov gorcunov at openvz.org
Wed Feb 8 08:02:57 EST 2012


If an error happens during late restore stage, we better
exit with error than dive into endless loop.

The loop was useful at early prototype times,
but not now when we use zdtm test suite.

For example, force injected error now reports

 | Restoring EXE (/home/crtools/test/zdtm/live/static/selfexe00)
 | 764
 | 11308
 | Error (cr-restore.c:1280): 11308 exited, status=255
 | Error (cr-restore.c:1412): Someone can't be restored

which is a way better than silent loop.

Reported-by: Pavel Emelyanov <xemul at parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 restorer.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/restorer.c b/restorer.c
index d67288b..a814cb1 100644
--- a/restorer.c
+++ b/restorer.c
@@ -228,9 +228,8 @@ long restore_thread(struct thread_restore_args *args)
 	core_restore_end:
 		write_num_n(__LINE__);
 		write_num_n(sys_getpid());
-		for (;;)
-			local_sleep(5);
-		sys_exit(0);
+		sys_exit(-1);
+		return -1;
 }
 
 static long restore_self_exe_late(struct task_restore_core_args *args)
@@ -764,7 +763,6 @@ long restore_task(struct task_restore_core_args *args)
 core_restore_end:
 	write_num_n(__LINE__);
 	write_num_n(sys_getpid());
-	for (;;)
-		local_sleep(5);
-	sys_exit(0);
+	sys_exit(-1);
+	return -1;
 }
-- 
1.7.7.6



More information about the CRIU mailing list