X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Flib_internal%2Fswitchtowatchxid.c;h=f88805d4c742f3c658630f83a43690e1d684fab1;hb=319929791248f823537ac5fb2fe10a01b5b820b9;hp=855e9dff6d805bacdcc9ed09894df16799d313a9;hpb=f2767d08f27e82e3d87c09b4da3be4ded0d23def;p=util-vserver.git diff --git a/util-vserver/lib_internal/switchtowatchxid.c b/util-vserver/lib_internal/switchtowatchxid.c index 855e9df..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,17 +35,35 @@ switchToWatchXid(char const **errptr) if (vc_get_task_xid(0)==1) return true; if (vc_isSupported(vcFEATURE_MIGRATE)) { - if (vc_create_context(1)==VC_NOCTX) { + 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; } - if (vc_migrate_context(1)==-1) { + if (vc_ctx_migrate(1)==-1) { if (errptr) *errptr = "vc_migrate_context()"; 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