The following commit has been merged in the master branch:
commit e844672595246c81f4a8e45ca842dc6aa3a4dbc8
Author: Guillem Jover <guil...@debian.org>
Date:   Wed May 26 02:37:42 2010 +0200

    build: Only use mmap in parser if explicitly requested
    
    The current mmap code is not reliable, as it does not handle SIGBUS,
    which can happen on I/O errors (among others). Switch the code to
    check for USE_MMAP instead of HAVE_MMAP so that it can be explicitly
    enabled on build, to produce consistent results by making sure it does
    not get reactivated accidentally. Disable it by default due to the
    above, in addition to not having been used by released tarballs since
    1.14.15.

diff --git a/configure.ac b/configure.ac
index 6e8c6b9..bf9a7b4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -127,6 +127,8 @@ DPKG_CHECK_COMPAT_FUNCS([getopt getopt_long obstack_free \
 AC_CHECK_FUNCS([strtoul isascii bcopy memcpy lchown setsid getdtablesize \
                 posix_fadvise])
 
+DPKG_MMAP
+
 AC_DEFINE(LIBDPKG_VOLATILE_API, 1, [Acknowledge the volatility of the API.])
 DPKG_COMPILER_WARNINGS
 DPKG_COMPILER_OPTIMISATIONS
diff --git a/lib/dpkg/parse.c b/lib/dpkg/parse.c
index c439a7f..b8ee07a 100644
--- a/lib/dpkg/parse.c
+++ b/lib/dpkg/parse.c
@@ -23,7 +23,7 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
-#ifdef HAVE_MMAP
+#ifdef USE_MMAP
 #include <sys/mman.h>
 #endif
 
@@ -121,7 +121,7 @@ int parsedb(const char *filename, enum parsedbflags flags,
     ohshite(_("can't stat package info file `%.255s'"),filename);
 
   if (st.st_size > 0) {
-#ifdef HAVE_MMAP
+#ifdef USE_MMAP
     dataptr = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
     if (dataptr == MAP_FAILED)
       ohshite(_("can't mmap package info file `%.255s'"),filename);
@@ -386,7 +386,7 @@ int parsedb(const char *filename, enum parsedbflags flags,
       ps.lno++;
   }
   if (data != NULL) {
-#ifdef HAVE_MMAP
+#ifdef USE_MMAP
     munmap(data, st.st_size);
 #else
     free(data);
diff --git a/m4/dpkg-funcs.m4 b/m4/dpkg-funcs.m4
index 188fa6b..3f0cf52 100644
--- a/m4/dpkg-funcs.m4
+++ b/m4/dpkg-funcs.m4
@@ -68,6 +68,22 @@ AS_IF([test "x$dpkg_cv_c99_snprintf" = "xyes"],
 AM_CONDITIONAL(HAVE_C99_SNPRINTF, [test "x$dpkg_cv_c99_snprintf" = "xyes"])
 ])# DPKG_FUNC_C99_SNPRINTF
 
+# DPKG_MMAP
+# ---------
+# Define USE_MMAP if mmap() is available and it was requested
+AC_DEFUN([DPKG_MMAP],
+[
+  AC_ARG_ENABLE([mmap],
+    AS_HELP_STRING([--enable-mmap],
+                   [enable usage of unrealiable mmap if available]),
+    [
+      AC_CHECK_FUNCS([mmap])
+      AC_DEFINE(USE_MMAP, 1, [Use unreliable mmap support])
+    ],
+    []
+  )
+])
+
 # DPKG_FUNC_ASYNC_SYNC
 # --------------------
 # Define HAVE_ASYNC_SYNC if sync() is asynchronous

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to