]> granicus.if.org Git - postgresql/commitdiff
Don't try to call posix_fadvise() unless <fcntl.h> supplies a declaration
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 18 Jun 2006 18:30:21 +0000 (18:30 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 18 Jun 2006 18:30:21 +0000 (18:30 +0000)
for it.  Hopefully will fix core dump evidenced by some buildfarm members
since fadvise patch went in.  The actual definition of the function is not
ABI-compatible with compiler's default assumption in the absence of any
declaration, so it's clearly unsafe to try to call it without seeing a
declaration.

configure
configure.in
src/backend/access/transam/xlog.c
src/include/pg_config.h.in

index f7947ebe72e51907b695e3a9c29d0e186bb55a98..5ef6be0cd16a5b0d328eeeb847ce08319850bacb 100755 (executable)
--- a/configure
+++ b/configure
@@ -13917,6 +13917,79 @@ _ACEOF
 fi
 
 
+echo "$as_me:$LINENO: checking whether posix_fadvise is declared" >&5
+echo $ECHO_N "checking whether posix_fadvise is declared... $ECHO_C" >&6
+if test "${ac_cv_have_decl_posix_fadvise+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <fcntl.h>
+
+int
+main ()
+{
+#ifndef posix_fadvise
+  char *p = (char *) posix_fadvise;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_have_decl_posix_fadvise=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_have_decl_posix_fadvise=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_have_decl_posix_fadvise" >&5
+echo "${ECHO_T}$ac_cv_have_decl_posix_fadvise" >&6
+if test $ac_cv_have_decl_posix_fadvise = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_POSIX_FADVISE 1
+_ACEOF
+
+
+else
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_POSIX_FADVISE 0
+_ACEOF
+
+
+fi
+
+
 
 HAVE_IPV6=no
 echo "$as_me:$LINENO: checking for struct sockaddr_in6" >&5
index 9075690fccb1b572e0228409e6f608a9e5c564d4..0f58eb7a4b809310f0f91522861c76497b45fbb4 100644 (file)
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-dnl $PostgreSQL: pgsql/configure.in,v 1.466 2006/06/07 22:24:43 momjian Exp $
+dnl $PostgreSQL: pgsql/configure.in,v 1.467 2006/06/18 18:30:20 tgl Exp $
 dnl
 dnl Developers, please strive to achieve this order:
 dnl
@@ -864,6 +864,7 @@ PGAC_FUNC_GETTIMEOFDAY_1ARG
 AC_CHECK_FUNCS([cbrt dlopen fcvt fdatasync getpeereid memmove poll pstat readlink setproctitle setsid sigprocmask symlink sysconf towlower utime utimes waitpid wcstombs])
 
 AC_CHECK_DECLS(fdatasync, [], [], [#include <unistd.h>])
+AC_CHECK_DECLS(posix_fadvise, [], [], [#include <fcntl.h>])
 
 HAVE_IPV6=no
 AC_CHECK_TYPE([struct sockaddr_in6],
index 57a8d1833d8fc6c670e105aea307144c9a173a9d..85618fcf01c8edbdaf2e25ca77bc34dd585fb59e 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.239 2006/06/16 04:11:48 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.240 2006/06/18 18:30:20 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -2147,11 +2147,13 @@ XLogFileClose(void)
 {
        Assert(openLogFile >= 0);
 
-#ifdef POSIX_FADV_DONTNEED
+#if defined(HAVE_DECL_POSIX_FADVISE) && defined(POSIX_FADV_DONTNEED)
        /*
-        * WAL caches will not be accessed in the future, so we advise OS to
-        * free them. But we will not do so if WAL archiving is active,
-        * because archivers might use the caches to read the WAL segment.
+        * WAL segment files will not be re-read in normal operation, so we advise
+        * OS to release any cached pages.  But do not do so if WAL archiving is
+        * active, because archiver process could use the cache to read the WAL
+        * segment.
+        *
         * While O_DIRECT works for O_SYNC, posix_fadvise() works for fsync()
         * and O_SYNC, and some platforms only have posix_fadvise().
         */
index 5ccfbfefd28f5b72e75d3a7f1ba43d1cb55773be..82ccde63c1c2f7b8cf45c493415be6200376b5ae 100644 (file)
    don't. */
 #undef HAVE_DECL_F_FULLFSYNC
 
+/* Define to 1 if you have the declaration of `posix_fadvise', and to 0 if you
+   don't. */
+#undef HAVE_DECL_POSIX_FADVISE
+
 /* Define to 1 if you have the declaration of `snprintf', and to 0 if you
    don't. */
 #undef HAVE_DECL_SNPRINTF