From aac8e6d930ef161186c3d25568dcc8cfa164a55e Mon Sep 17 00:00:00 2001
From: David Hedbor <david@hedbor.org>
Date: Thu, 10 Aug 1995 13:41:27 +0200
Subject: [PATCH] lite bugg fix

Rev: src/configure.in:1.2
Rev: src/main.c:1.2
---
 src/configure.in |  3 ++-
 src/main.c       | 11 ++++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/configure.in b/src/configure.in
index 0aa4bb2418..4dff0237c8 100644
--- a/src/configure.in
+++ b/src/configure.in
@@ -105,7 +105,8 @@ LIBOBJS="${OLD_LIBOBJS}"
 
 AC_HAVE_FUNCS(memset memcpy memchr strchr strrchr fchmod getrusage \
  strcspn crypt _crypt getwd getcwd strtod strtok getenv vfprintf bzero bcopy \
- strtol index rindex vsprintf clock times setlocale strcoll getrlimit setrlimit)
+ strtol index rindex vsprintf clock times setlocale strcoll getrlimit \
+ setrlimit setdtablesize)
 
 define(MY_CHECK_HEADERS,
 [
diff --git a/src/main.c b/src/main.c
index 0c87dbd58c..fbe793ad61 100644
--- a/src/main.c
+++ b/src/main.c
@@ -23,8 +23,13 @@
 #endif
 #ifdef HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
+#if defined (RLIMIT_OFILE) && !defined (RLIMIT_NOFILE)
+#  define RLIMIT_NOFILE RLIMIT_OFILE
+#endif /* HAVE_RESOURCE && RLIMIT_OFILE && !RLIMIT_NOFILE */
 #endif
 
+/* Some systems use RLIMIT_NOFILE, others use RLIMIT_OFILE */
+
 char *master_file;
 
 int d_flag=0;
@@ -126,7 +131,7 @@ void main(int argc, char **argv, char **env)
     }
   }
 
-#ifdef HAVE_SETRLIMIT
+#if defined(HAVE_SETRLIMIT) && defined(RLIMIT_NOFILE)
   {
     struct rlimit lim;
     int tmp;
@@ -139,6 +144,10 @@ void main(int argc, char **argv, char **env)
       setrlimit(RLIMIT_NOFILE, &lim);
     }
   }
+#else
+#if defined (HAVE_SETDTABLESIZE)
+  setdtablesize (MAX_OPEN_FILEDESCRIPTORS);
+#endif
 #endif
 
   current_time = get_current_time();
-- 
GitLab