From: Liu Chao liuchao173@huawei.com
Conflict:NA Reference:https://gitee.com/src-openeuler/criu/pulls/21 Signed-off-by: fu.lin fu.lin10@huawei.com --- criu/cr-restore.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/criu/cr-restore.c b/criu/cr-restore.c index ed82524..4fd29a5 100644 --- a/criu/cr-restore.c +++ b/criu/cr-restore.c @@ -111,6 +111,9 @@ #endif
struct pstree_item *current; +#define NETWORK_COLLECTED 0x1 +#define NETWORK_UNLOCK 0x2 +static int network_status = 0;
static int restore_task_with_children(void *); static int sigreturn_restore(pid_t pid, struct task_restore_args *ta, unsigned long alen, CoreEntry *core); @@ -247,6 +250,7 @@ static int crtools_prepare_shared(void) /* Connections are unlocked from criu */ if (!files_collected() && collect_image(&inet_sk_cinfo)) return -1; + network_status |= NETWORK_COLLECTED;
if (collect_binfmt_misc()) return -1; @@ -2496,6 +2500,7 @@ skip_ns_bouncing:
/* Unlock network before disabling repair mode on sockets */ network_unlock(); + network_status |= NETWORK_UNLOCK;
/* * Stop getting sigchld, after we resume the tasks they @@ -2701,6 +2706,15 @@ int cr_restore_tasks(void)
err: cr_plugin_fini(CR_PLUGIN_STAGE__RESTORE, ret); + if (ret < 0) { + if ((network_status & NETWORK_COLLECTED) == 0) { + if (!files_collected() && collect_image(&inet_sk_cinfo)) + pr_err("collect inet sk cinfo fail"); + } + if ((network_status & NETWORK_UNLOCK) == 0) + network_unlock(); + } + return ret; }