vc_getVserverByCtx_*(): added 'validate_result' parameter to avoid
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Tue, 25 Oct 2005 16:20:07 +0000 (16:20 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Tue, 25 Oct 2005 16:20:07 +0000 (16:20 +0000)
recursion when called by getvserverctx()

git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2182 94cd875c-1c1d-0410-91d2-eb244daf1a30

util-vserver/lib/getvserverbyctx-compat.hc
util-vserver/lib/getvserverbyctx-v13.hc
util-vserver/lib/getvserverbyctx.c

index 9418e2f..79ceef6 100644 (file)
@@ -67,7 +67,8 @@ handleLegacy(xid_t UNUSED xid)
 #endif
 
 static char *
-vc_getVserverByCtx_compat(xid_t ctx, vcCfgStyle *style, char const *revdir)
+vc_getVserverByCtx_compat(xid_t ctx, vcCfgStyle *style, char const *revdir,
+                         bool validate_result)
 {
   if (revdir==0) revdir = DEFAULT_PKGSTATEREVDIR;
 
@@ -92,8 +93,10 @@ vc_getVserverByCtx_compat(xid_t ctx, vcCfgStyle *style, char const *revdir)
   switch (cur_style) {
     case vcCFG_RECENT_SHORT    :
     case vcCFG_RECENT_FULL     :
-       // check if expected ctx == actual ctx
-      if (vc_getVserverCtx(path, vcCFG_RECENT_FULL, false, 0)!=ctx) return 0;
+       // check if expected ctx == actual ctx (but only when this check is
+       // request)
+      if (validate_result &&
+         vc_getVserverCtx(path, vcCFG_RECENT_FULL, false, 0)!=ctx) return 0;
 
       if (style) *style = vcCFG_RECENT_FULL;
       return strdup(path);
index 7cd90a8..d9f601b 100644 (file)
 #endif
 
 static char *
-vc_getVserverByCtx_v13(xid_t ctx, vcCfgStyle *style, char const UNUSED *revdir)
+vc_getVserverByCtx_v13(xid_t ctx, vcCfgStyle *style, char const UNUSED *revdir,
+                      bool validate_result)
 {
   char         buf[128];
 
   if (vc_get_vhi_name(ctx, vcVHI_CONTEXT, buf, sizeof buf)!=-1 &&
-      vc_getVserverCtx(buf, vcCFG_RECENT_FULL, false, 0)==ctx) {
+      (!validate_result ||
+       vc_getVserverCtx(buf, vcCFG_RECENT_FULL, false, 0)==ctx)) {
     if (style) *style = vcCFG_RECENT_FULL;
     return strdup(buf);
   }
index 8ceda6f..0519f7b 100644 (file)
 #include "getvserverbyctx-compat.hc"
 #include "getvserverbyctx-v13.hc"
 
+
 char *
-vc_getVserverByCtx(xid_t ctx, vcCfgStyle *style, char const *revdir)
+vc_getVserverByCtx_Internal(xid_t ctx, /*@null@*/vcCfgStyle *style,
+                           /*@null@*/char const *revdir,
+                           bool validate_result)
 {
   if (vc_isSupported(vcFEATURE_MIGRATE))
-    return vc_getVserverByCtx_v13(ctx, style, revdir);
+    return vc_getVserverByCtx_v13(ctx, style, revdir, validate_result);
   else
-    return vc_getVserverByCtx_compat(ctx, style, revdir);
+    return vc_getVserverByCtx_compat(ctx, style, revdir, validate_result);
+}
+
+char *
+vc_getVserverByCtx(xid_t ctx, vcCfgStyle *style, char const *revdir)
+{
+  return vc_getVserverByCtx_Internal(ctx, style, revdir, true);
+  
 }