Commit f42810ca authored by Per Cederqvist's avatar Per Cederqvist
Browse files

Define HAVE_BROKEN_NOFILE if setrlimit(RLIMIT_NOFILE) fails.

parent e1055bea
dnl $Id: configure.in,v 1.91 2002/10/06 07:22:23 ceder Exp $
dnl $Id: configure.in,v 1.92 2002/10/26 21:42:04 ceder Exp $
dnl Configuration for LysKOM
dnl Copyright (C) 1993-2002 Lysator Academic Computer Association.
dnl
......@@ -18,7 +18,7 @@ dnl Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
dnl
dnl Please mail bug reports to bug-lyskom@lysator.liu.se.
dnl
AC_REVISION($Revision: 1.91 $)
AC_REVISION($Revision: 1.92 $)
AC_PREREQ(2.53)
AC_INIT([lyskom-server], [2.0.7])
AC_CONFIG_SRCDIR([src/server/lyskomd.h])
......@@ -354,6 +354,89 @@ AC_CHECK_FUNCS(difftime getdtablesize sysconf strchr getcwd vfprintf)
AC_CHECK_FUNCS(setrlimit)
AC_REPLACE_FUNCS(memcpy strerror remove memset memchr memcmp setsid)
dnl
dnl On AIX 4.2, setrlimit(RLIMIT_NOFILE) doesn't work. The
dnl RLIMIT_NOFILE limit is ignored, and getrlimit(RLIMIT_NOFILE)
dnl always returns 2147483647. Not very helpful.
[if test $ac_cv_func_setrlimit = yes
then]
AC_CACHE_CHECK([for working setrlimit(RLIMIT_NOFILE, ...)],
kom_cv_func_rlimit_nofile,
AC_TRY_RUN([
#include <stdio.h>
#ifdef HAVE_SYS_RESOURCE_H
# ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
# else
# ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
# endif
# include <sys/resource.h>
#else
# include <time.h>
#endif
#include <fcntl.h>
#if defined(HAVE_SETRLIMIT) && defined(RLIMIT_OFILE) && !defined(RLIMIT_NOFILE)
# define RLIMIT_NOFILE RLIMIT_OFILE
#endif
#if !HAVE_RLIM_T
typedef int rlim_t;
#endif
int main()
{
#if defined(HAVE_SETRLIMIT) && defined(RLIMIT_NOFILE)
struct rlimit rlim;
int i;
int fd;
if (getrlimit(RLIMIT_NOFILE, &rlim) < 0)
{
perror("getrlimit(RLIMIT_NOFILE) failed");
return 1;
}
rlim.rlim_cur = 20;
if (setrlimit(RLIMIT_NOFILE, &rlim) < 0)
{
perror("setrlimit(RLIMIT_NOFILE) failed");
return 1;
}
if (getrlimit(RLIMIT_NOFILE, &rlim) < 0)
{
perror("second getrlimit(RLIMIT_NOFILE) failed");
return 1;
}
if (rlim.rlim_cur != 20)
{
fprintf(stderr, "NOFILE set to %ld, not 20\n", (long)rlim.rlim_cur);
return 1;
}
for (i = 0; i < 25; i++)
if ((fd = open("/dev/null", O_WRONLY)) > 19)
{
fprintf(stderr, "NOFILE doesn't limit files; got fd %d\n", fd);
return 1;
}
return 0;
#else
fprintf(stderr, "setrlimit not available\n");
return 1;
#endif
}], [kom_cv_func_rlimit_nofile=yes],
[kom_cv_func_rlimit_nofile=no],
[kom_cv_func_rlimit_nofile=no]))
[if test $kom_cv_func_rlimit_nofile = no
then]
AC_DEFINE([HAVE_BROKEN_NOFILE], [1],
[Define if setrlimit(RLIMIT_NOFILE) does not work.])
[fi
fi]
dnl
dnl strdup() is not currently used, but we have a replacement function
dnl since it was used a while ago. No need to take up time looking
dnl for it, though. Remove strdup.c from EXTRA_DIST in
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment