[CRIU] [PATCH] dump: don't call rollback actions from a signal handler

Andrey Vagin avagin at openvz.org
Thu Feb 18 13:30:53 PST 2016


From: Andrew Vagin <avagin at virtuozzo.com>

We can do this, but we need to be sure that all structures
are consistant in any moment and we need to block alarm when
they are inconsistant.

I don't think that we really want to do this now. I suggest to
interupt a current syscall if an alarm signal is triggered.

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

Cc: Andrey Ryabinin <aryabinin at virtuozzo.com>
Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 criu/cr-dump.c | 39 +++++++++++++++++----------------------
 1 file changed, 17 insertions(+), 22 deletions(-)

diff --git a/criu/cr-dump.c b/criu/cr-dump.c
index 8f2587b..140e413 100644
--- a/criu/cr-dump.c
+++ b/criu/cr-dump.c
@@ -1366,13 +1366,24 @@ err_cure_imgset:
 	goto err;
 }
 
-typedef void (*sa_handler_t)(int);
+static void alarm_handler(int signo)
+{
+	static int cnt = 5;
+
+	pr_err("Timeout reached. Try to interrupt: %d\n", signo);
+	if (cnt--) {
+		alarm(1);
+		/* A curren syscall will be exited with EINTR */
+		return;
+	}
+	exit(1);
+}
 
-static int setup_alarm_handler(sa_handler_t handler)
+static int setup_alarm_handler()
 {
 	struct sigaction sa = {
-		.sa_handler	= handler,
-		.sa_flags	= 0,
+		.sa_handler	= alarm_handler,
+		.sa_flags	= 0, /* Don't restart syscalls */
 	};
 
 	sigemptyset(&sa.sa_mask);
@@ -1437,15 +1448,6 @@ static int cr_pre_dump_finish(struct list_head *ctls, int ret)
 	return ret;
 }
 
-void pre_dump_alarm_handler(int signum)
-{
-	LIST_HEAD(empty_list);
-
-	pr_err("Timeout reached\n");
-	cr_pre_dump_finish(&empty_list, -1);
-	exit(-1);
-}
-
 int cr_pre_dump_tasks(pid_t pid)
 {
 	struct pstree_item *item;
@@ -1483,7 +1485,7 @@ int cr_pre_dump_tasks(pid_t pid)
 	if (connect_to_page_server())
 		goto err;
 
-	if (setup_alarm_handler(pre_dump_alarm_handler))
+	if (setup_alarm_handler())
 		goto err;
 
 	if (collect_pstree(pid))
@@ -1585,13 +1587,6 @@ static int cr_dump_finish(int ret)
 	return post_dump_ret ? : (ret != 0);
 }
 
-void dump_alarm_handler(int signum)
-{
-	pr_err("Timeout reached\n");
-	cr_dump_finish(-1);
-	exit(-1);
-}
-
 int cr_dump_tasks(pid_t pid)
 {
 	InventoryEntry he = INVENTORY_ENTRY__INIT;
@@ -1640,7 +1635,7 @@ int cr_dump_tasks(pid_t pid)
 	if (connect_to_page_server())
 		goto err;
 
-	if (setup_alarm_handler(dump_alarm_handler))
+	if (setup_alarm_handler())
 		goto err;
 
 	/*
-- 
2.5.0



More information about the CRIU mailing list