[PATCH] Squid incorrectly detects Linux 2.1+'s FDs

From: Jordan Mendelson <jordy@dont-contact.us>
Date: Mon, 8 Feb 1999 11:52:19 -0500 (EST)

Here is a patch for Squid 2.2 PRE2 which correctly detects Linux 2.1 and
Linux 2.2's file descriptors as well as previous versions. I have tested
this on Linux 2.2.1 with Glibc 2 and Linux 2.0.35 with Libc5.

Linus has stated that OPEN_MAX will not change in kernel headers and it is
unreliable to use it to check and Glibc puts in it's own headers which
also force the configure script to default to 256. getrlimit() provides a
reliable way to get the maximum file descriptors.

Jordan

--
Jordan Mendelson     : http://jordy.wserv.com
Web Services, Inc.   : http://www.wserv.com

*** configure.OLD Mon Feb 8 11:40:26 1999
--- configure Mon Feb 8 11:42:17 1999
***************
*** 4359,4365 ****
      }
  #endif /* RLIMIT_NOFILE */
  #endif /* HAVE_SETRLIMIT */
! #if HAVE_SYSCONF && defined(_SC_OPEN_MAX)
          i = sysconf(_SC_OPEN_MAX);
  #elif HAVE_GETDTABLESIZE && !defined(__linux__)
          i = getdtablesize();
--- 4359,4373 ----
      }
  #endif /* RLIMIT_NOFILE */
  #endif /* HAVE_SETRLIMIT */
! #if defined(__linux__) && defined(HAVE_SETRLIMIT)
! /* linux 2.1 and higher don't set OPEN_MAX correctly and must use
! * getrlimit() to poll correct number of fds (1024 in 2.1, 256 in
! * 2.0 by default) */
! if (getrlimit(RLIMIT_NOFILE, &rl) < 0) {
! perror("getrlimit: RLIMIT_NOFILE");
! }
! i = rl.rlim_cur;
! #elif HAVE_SYSCONF && defined(_SC_OPEN_MAX)
          i = sysconf(_SC_OPEN_MAX);
  #elif HAVE_GETDTABLESIZE && !defined(__linux__)
          i = getdtablesize();
*** configure.in.OLD Mon Feb 8 11:46:01 1999
--- configure.in Mon Feb 8 11:46:32 1999
***************
*** 1078,1084 ****
      }
  #endif /* RLIMIT_NOFILE */
  #endif /* HAVE_SETRLIMIT */
! #if HAVE_SYSCONF && defined(_SC_OPEN_MAX)
          i = sysconf(_SC_OPEN_MAX);
  #elif HAVE_GETDTABLESIZE && !defined(__linux__)
          i = getdtablesize();
--- 1078,1089 ----
      }
  #endif /* RLIMIT_NOFILE */
  #endif /* HAVE_SETRLIMIT */
! #if defined(__linux__) && defined(HAVE_SETRLIMIT)
! if (getrlimit(RLIMIT_NOFILE, &rl) < 0) {
! perror("getrlimit: RLIMIT_NOFILE");
! }
! i = rl.rlim_cur;
! #elif HAVE_SYSCONF && defined(_SC_OPEN_MAX)
          i = sysconf(_SC_OPEN_MAX);
  #elif HAVE_GETDTABLESIZE && !defined(__linux__)
          i = getdtablesize();
Received on Mon Feb 08 1999 - 09:57:51 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:44:29 MST