Optimize the 0.0.0.0 case, and get it working on 2.3 kernels.
authorDaniel Hokka Zakrisson <dhokka@cs.princeton.edu>
Sat, 24 Oct 2009 21:38:07 +0000 (21:38 +0000)
committerDaniel Hokka Zakrisson <dhokka@cs.princeton.edu>
Sat, 24 Oct 2009 21:38:07 +0000 (21:38 +0000)
python/vserver.py

index 8aa410e..081fd8a 100644 (file)
@@ -129,6 +129,26 @@ class VServerConfig:
         os.path.walk(self.dir, add_to_cache, self.cache)
 
 
+def adjust_lim(goal, curr):
+    gh = goal[0]
+    gs = goal[1]
+    gm = goal[2]
+    soft = curr[0]
+    hard = curr[1]
+    if gm != VC_LIM_KEEP:
+        if gm > soft:
+            soft = gm
+        if gm > hard:
+            hard = gm
+    if gs != VC_LIM_KEEP:
+        if gs > soft:
+            soft = gs
+    if gh != VC_LIM_KEEP:
+        if gh > hard:
+            hard = gh
+    return (soft, hard)
+
+
 class VServer:
 
     INITSCRIPTS = [('/etc/rc.vinit', 'start'),
@@ -181,6 +201,9 @@ class VServer:
             resource_type = RLIMITS[type]
             try:
                 vserverimpl.setrlimit(self.ctx, resource_type, hard, soft, min)
+                lim = resource.getrlimit(resource_type)
+                lim = adjust_lim((hard, soft, min), lim)
+                resource.setrlimit(resource_type, lim)
             except OSError, e:
                 self.log("Error: setrlimit(%d, %s, %d, %d, %d): %s"
                          % (self.ctx, type.lower(), hard, soft, min))