From 72e4537b1629dc1c659fce66b201a62fff967842 Mon Sep 17 00:00:00 2001 From: Enrico Scholz Date: Tue, 11 May 2004 18:23:56 +0000 Subject: [PATCH] switchToWatchXid(): modified the new migrate-path to work when there exists a process in xid 1 already git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@1555 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- util-vserver/lib_internal/switchtowatchxid.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/util-vserver/lib_internal/switchtowatchxid.c b/util-vserver/lib_internal/switchtowatchxid.c index cea37fe..f88805d 100644 --- a/util-vserver/lib_internal/switchtowatchxid.c +++ b/util-vserver/lib_internal/switchtowatchxid.c @@ -22,6 +22,7 @@ #include #include +#include // try to switch in context 1 bool @@ -34,7 +35,14 @@ switchToWatchXid(char const **errptr) if (vc_get_task_xid(0)==1) return true; if (vc_isSupported(vcFEATURE_MIGRATE)) { + int max_tries = 20; + again: if (vc_ctx_create(1)==VC_NOCTX) { + if (errno==EBUSY && --max_tries>0) { + usleep(50000); + goto again; + } + if (errno!=EEXIST) { if (errptr) *errptr = "vc_create_context()"; return false; @@ -45,6 +53,17 @@ switchToWatchXid(char const **errptr) return false; } } + else { + struct vc_ctx_flags flags = { + .flagword = 0, + .mask = VC_VXF_STATE_SETUP, + }; + + if (vc_set_cflags(1, &flags)==-1) { + if (errptr) *errptr = "vc_set_cflags()"; + return false; + } + } } else { #if VC_ENABLE_API_COMPAT -- 1.8.1.5