X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=utils%2Fmountd%2Fmountd.c;h=0d4ddb43970a762e4a5547ec0f6f61d2cd825cb4;hb=06c962bc87aba28a3169be6a18ce8d52060b661f;hp=0b34617dbb41261b2f5920c80df7858699942da0;hpb=2ff7a4def6b60f2d1868d3da2a537b90ee058d30;p=nfs-utils.git diff --git a/utils/mountd/mountd.c b/utils/mountd/mountd.c index 0b34617..0d4ddb4 100644 --- a/utils/mountd/mountd.c +++ b/utils/mountd/mountd.c @@ -504,18 +504,21 @@ main(int argc, char **argv) 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)); - 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. */