diff --git a/src/configure.in b/src/configure.in index 0aa4bb2418be01dda9cea12e7519c94c25cea154..4dff0237c8d5360904c4af5b03ab702fbf4dbba9 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 0c87dbd58c1d2686f3e32a1355f9c18ccb93e3ed..fbe793ad61191e4cd95a41cf1bc7b99307494773 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();