The following patch and file allows for the detection and use of POSIX
large file implentations that exist in most modern OSes.

"Large files" refers to files that are greater than 2GB in size. Without
LF support, a program will typically crash or otherwise fail if an attempt
is made to open or write/read to a file (or memeory-mapped region) that is
over 2GB in size.

In terms of Apache, this allows log files to grow beyond 2GB, as well as
the ability to serve files that are > 2GB.

*Possible* Caveat: Attempting to serve a large file over a SSL connection
can possibly fail. This is not the fault of Apache or APR, but with the
OpenSSL routines that Apache uses to manage SSL connections. A work-around
is to recompile OpenSSL with large file support, or to serve the content
via a non-SSL connetion if possible.

I havnt had the time to test this theory, but I ran into it while
benchmarking OpenSSH (which uses OpenSSL) not too long ago. The fix there
as to recompile OpenSSL with LF support. I gather the situation would be
the same here, too. If anyone has a chance to give this a whirl, let me or
the list know.

Anyhow, the patch to apr/configure.in and a new file,
apr/build/apr_largefile.m4 are attached.

/dale





Index: apr/configure.in
===================================================================
RCS file: /home/cvspublic/apr/configure.in,v
retrieving revision 1.474
diff -u -r1.474 configure.in
--- apr/configure.in    5 Aug 2002 09:28:24 -0000       1.474
+++ apr/configure.in    13 Aug 2002 22:13:19 -0000
@@ -14,6 +14,7 @@
 sinclude(build/apr_common.m4)
 sinclude(build/apr_network.m4)
 sinclude(build/apr_threads.m4)
+sinclude(build/apr_largefile.m4)
 sinclude(build/apr_hints.m4)
 sinclude(build/libtool.m4)
 
@@ -299,6 +300,26 @@
        APR_SETVAR(AR,ar)
        ;;
 esac
+
+dnl Disable largefiles on OSes that support largefiles.
+dnl Largefiles is enabled by default
+AC_ARG_ENABLE(largefiles,
+[  --disable-largefiles    Disable support for large (>2GB) files],
+[
+    if test "$enableval" = "no"; then
+        user_disabled_largefiles=1
+    fi ],
+[
+    user_disabled_largefiles=0
+])
+
+AC_MSG_CHECKING(whether to enable large file support)
+if test "$user_disabled_largefiles" = 1; then
+    AC_MSG_RESULT(no -- disabled by user)
+else
+    AC_MSG_RESULT(yes -- determining needed flags...) 
+    APR_SYS_LARGEFILE
+fi
 
 dnl force_atomic_generic flag 
 dnl this will be set we find a cpu/OS combo
dnl By default, many hosts won't let programs access large files;
dnl one must use special compiler options to get large-file access to work.
dnl For more details about this brain damage please see:
dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html

dnl Written by Paul Eggert <[EMAIL PROTECTED]>.
dnl (Modified to not collide with autoconf 2.50+'s AC_SYS_LARGEFILE)

dnl Modified by Dale Ghent <[EMAIL PROTECTED]>
dnl for a better fit into the APR autoconf adventure.

dnl Internal subroutine of APR_SYS_LARGEFILE.
dnl APR_SYS_LARGEFILE_TEST_INCLUDES
AC_DEFUN(APR_SYS_LARGEFILE_TEST_INCLUDES,
  [[#include <sys/types.h>
    /* Check that off_t can represent 2**63 - 1 correctly.
       We can't simply "#define LARGE_OFF_T 9223372036854775807",
       since some C++ compilers masquerading as C compilers
       incorrectly reject 9223372036854775807.  */
#   define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
    int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
                        && LARGE_OFF_T % 2147483647 == 1)
                       ? 1 : -1];
  ]])

dnl Internal subroutine of APR_SYS_LARGEFILE.
dnl APR_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR, COMMENT, INCLUDES, 
FUNCTION-BODY)
AC_DEFUN(APR_SYS_LARGEFILE_MACRO_VALUE,
  [AC_CACHE_CHECK([for $1 value needed for large files], $3,
     [$3=no
      AC_TRY_COMPILE([$5],
        [$6],
        ,
        [AC_TRY_COMPILE([#define $1 $2]
[$5]
           ,
           [$6],
           [$3=$2])])])
   if test "[$]$3" != no; then
     APR_ADDTO(CPPFLAGS, [-D$1=$2])
   fi])

AC_DEFUN(APR_SYS_LARGEFILE,
  [AC_REQUIRE([AC_PROG_CC])
     AC_CACHE_CHECK([for special C compiler options needed for large files],
       ac_cv_sys_largefile_CC,
       [ac_cv_sys_largefile_CC=no
        if test "$GCC" != yes; then
          # IRIX 6.2 and later do not support large files by default,
          # so use the C compiler's -n32 option if that helps.
          AC_TRY_COMPILE(APR_SYS_LARGEFILE_TEST_INCLUDES, , ,
            [ac_save_CC="$CC"
             CC="$CC -n32"
             AC_TRY_COMPILE(APR_SYS_LARGEFILE_TEST_INCLUDES, ,
               ac_cv_sys_largefile_CC=' -n32')
             CC="$ac_save_CC"])
        fi])
     if test "$ac_cv_sys_largefile_CC" != no; then
       CC="$CC$ac_cv_sys_largefile_CC"
     fi

     APR_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
       ac_cv_sys_file_offset_bits,
       [Number of bits in a file offset, on hosts where this is settable.],
       APR_SYS_LARGEFILE_TEST_INCLUDES)
     APR_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
       ac_cv_sys_large_files,
       [Define for large files, on AIX-style hosts.],
       APR_SYS_LARGEFILE_TEST_INCLUDES)
  ])

Reply via email to