]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
Work around RLIMIT_NOFILE-to-big problem nfs-utils-1-0-5-post2nfs-utils-1-0-5-post3
authorneilbrown <neilbrown>
Fri, 12 Sep 2003 06:37:16 +0000 (06:37 +0000)
committerneilbrown <neilbrown>
Fri, 12 Sep 2003 06:37:16 +0000 (06:37 +0000)
ChangeLog
utils/mountd/mountd.c
utils/statd/statd.c

index a9f2fcf4a00daf164951582ed2ce09f692351899..53514b239bf33efc8d5a8dcd142b03514d2ae2ef 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2003-09-12 NeilBrown <neilb@cse.unsw.edu.au>
+       * utils/mountd/mountd.c(main): Impose FD_SETSIZE as an upper limit
+       for RLIMIT_NOFILE
+       * utils/statd/statd.c(main): Ditto.
+
+        michael <michael@newdream.net> discovered that svc_setreqsize in
+       glibc can segfault if RLIMIT_NOFILE is bigger than FD_SETSIZE,
+       so a simple solution is to impose a hard limit.
+
 2003-09-09  Chip Salzenberg  <chip@pobox.com>
 
        * debian/changelog: Version 1.0.5-3.
 2003-09-09  Chip Salzenberg  <chip@pobox.com>
 
        * debian/changelog: Version 1.0.5-3.
index 0b34617dbb41261b2f5920c80df7858699942da0..0d4ddb43970a762e4a5547ec0f6f61d2cd825cb4 100644 (file)
@@ -504,18 +504,21 @@ main(int argc, char **argv)
                exit(1);
        }
 
                exit(1);
        }
 
-       if (descriptors) {
-               if (getrlimit (RLIMIT_NOFILE, &rlim) != 0) {
-                       fprintf(stderr, "%s: getrlimit (RLIMIT_NOFILE) failed: %s\n",
+       if (getrlimit (RLIMIT_NOFILE, &rlim) != 0)
+               fprintf(stderr, "%s: getrlimit (RLIMIT_NOFILE) failed: %s\n",
                                argv [0], strerror(errno));
                                argv [0], strerror(errno));
-                       exit(1);
-               }
-
-               rlim.rlim_cur = descriptors;
-               if (setrlimit (RLIMIT_NOFILE, &rlim) != 0) {
-                       fprintf(stderr, "%s: setrlimit (RLIMIT_NOFILE) failed: %s\n",
-                               argv [0], strerror(errno));
-                       exit(1);
+       else {
+               /* glibc sunrpc code dies if getdtablesize > FD_SETSIZE */
+               if (descriptors == 0 && rlim.rlim_cur > FD_SETSIZE)
+                       descriptors = FD_SETSIZE;
+               if (descriptors) {
+
+                       rlim.rlim_cur = descriptors;
+                       if (setrlimit (RLIMIT_NOFILE, &rlim) != 0) {
+                               fprintf(stderr, "%s: setrlimit (RLIMIT_NOFILE) failed: %s\n",
+                                       argv [0], strerror(errno));
+                               exit(1);
+                       }
                }
        }
        /* Initialize logging. */
                }
        }
        /* Initialize logging. */
index 93c394f160401fa896dfece800cb2ea09d022b64..b57f71bb0091bf1bc46096e5dbb996d88cc33107 100644 (file)
@@ -18,6 +18,7 @@
 #include <rpc/rpc.h>
 #include <rpc/pmap_clnt.h>
 #include <rpcmisc.h>
 #include <rpc/rpc.h>
 #include <rpc/pmap_clnt.h>
 #include <rpcmisc.h>
+#include <sys/resource.h>
 #include <grp.h>
 #include "statd.h"
 #include "version.h"
 #include <grp.h>
 #include "statd.h"
 #include "version.h"
@@ -209,6 +210,7 @@ int main (int argc, char **argv)
        int pid;
        int arg;
        int port = 0, out_port = 0;
        int pid;
        int arg;
        int port = 0, out_port = 0;
+       struct rlimit rlim;
 
        int pipefds[2] = { -1, -1};
        char status;
 
        int pipefds[2] = { -1, -1};
        char status;
@@ -320,6 +322,21 @@ int main (int argc, char **argv)
                                                   daemon mode. */
        }
 
                                                   daemon mode. */
        }
 
+       if (getrlimit (RLIMIT_NOFILE, &rlim) != 0)
+               fprintf(stderr, "%s: getrlimit (RLIMIT_NOFILE) failed: %s\n",
+                               argv [0], strerror(errno));
+       else {
+               /* glibc sunrpc code dies if getdtablesize > FD_SETSIZE */
+               if (rlim.rlim_cur > FD_SETSIZE) {
+                       rlim.rlim_cur = FD_SETSIZE;
+
+                       if (setrlimit (RLIMIT_NOFILE, &rlim) != 0) {
+                               fprintf(stderr, "%s: setrlimit (RLIMIT_NOFILE) failed: %s\n",
+                                       argv [0], strerror(errno));
+                       }
+               }
+       }
+
 #ifdef SIMULATIONS
        if (argc > 1)
                /* LH - I _really_ need to update simulator... */
 #ifdef SIMULATIONS
        if (argc > 1)
                /* LH - I _really_ need to update simulator... */