]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
node.py: try to fix RLIMIT_NOFILE on solaris too
authorBrian Warner <warner@allmydata.com>
Fri, 16 Nov 2007 06:06:44 +0000 (23:06 -0700)
committerBrian Warner <warner@allmydata.com>
Fri, 16 Nov 2007 06:06:44 +0000 (23:06 -0700)
src/allmydata/node.py

index c9afa80db6e83c42ff940af1e77d416bb523883c..e9dc19f438aca35f4b26e284c5a80c306790a736 100644 (file)
@@ -105,14 +105,19 @@ class Node(service.MultiService):
             return
 
         try:
-            # this one works on OS-X (bsd), and gives us 10240, but
-            # it doesn't work on linux (on which both the hard and
-            # soft limits are set to 1024 by default).
-            resource.setrlimit(resource.RLIMIT_NOFILE, (-1,-1))
-            new = resource.getrlimit(resource.RLIMIT_NOFILE)[0]
-            if new == current:
-                # probably cygwin, which ignores -1. Use a real value.
-                resource.setrlimit(resource.RLIMIT_NOFILE, (3200,-1))
+            if current[1] > 0 and current[1] < 1000000:
+                # solaris reports (256, 65536)
+                resource.setrlimit(resource.RLIMIT_NOFILE,
+                                   (current[1], current[1]))
+            else:
+                # this one works on OS-X (bsd), and gives us 10240, but
+                # it doesn't work on linux (on which both the hard and
+                # soft limits are set to 1024 by default).
+                resource.setrlimit(resource.RLIMIT_NOFILE, (-1,-1))
+                new = resource.getrlimit(resource.RLIMIT_NOFILE)[0]
+                if new == current:
+                    # probably cygwin, which ignores -1. Use a real value.
+                    resource.setrlimit(resource.RLIMIT_NOFILE, (3200,-1))
 
         except ValueError:
             self.log("unable to set RLIMIT_NOFILE: current value %s"