Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1e8ae13

Browse files
committed
Don't try to call posix_fadvise() unless <fcntl.h> supplies a declaration
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.
1 parent 2204566 commit 1e8ae13

File tree

4 files changed

+86
-6
lines changed

4 files changed

+86
-6
lines changed

configure

+73
Original file line numberDiff line numberDiff line change
@@ -13917,6 +13917,79 @@ _ACEOF
1391713917
fi
1391813918

1391913919

13920+
echo "$as_me:$LINENO: checking whether posix_fadvise is declared" >&5
13921+
echo $ECHO_N "checking whether posix_fadvise is declared... $ECHO_C" >&6
13922+
if test "${ac_cv_have_decl_posix_fadvise+set}" = set; then
13923+
echo $ECHO_N "(cached) $ECHO_C" >&6
13924+
else
13925+
cat >conftest.$ac_ext <<_ACEOF
13926+
/* confdefs.h. */
13927+
_ACEOF
13928+
cat confdefs.h >>conftest.$ac_ext
13929+
cat >>conftest.$ac_ext <<_ACEOF
13930+
/* end confdefs.h. */
13931+
#include <fcntl.h>
13932+
13933+
int
13934+
main ()
13935+
{
13936+
#ifndef posix_fadvise
13937+
char *p = (char *) posix_fadvise;
13938+
#endif
13939+
13940+
;
13941+
return 0;
13942+
}
13943+
_ACEOF
13944+
rm -f conftest.$ac_objext
13945+
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
13946+
(eval $ac_compile) 2>conftest.er1
13947+
ac_status=$?
13948+
grep -v '^ *+' conftest.er1 >conftest.err
13949+
rm -f conftest.er1
13950+
cat conftest.err >&5
13951+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
13952+
(exit $ac_status); } &&
13953+
{ ac_try='test -z "$ac_c_werror_flag"
13954+
|| test ! -s conftest.err'
13955+
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
13956+
(eval $ac_try) 2>&5
13957+
ac_status=$?
13958+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
13959+
(exit $ac_status); }; } &&
13960+
{ ac_try='test -s conftest.$ac_objext'
13961+
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
13962+
(eval $ac_try) 2>&5
13963+
ac_status=$?
13964+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
13965+
(exit $ac_status); }; }; then
13966+
ac_cv_have_decl_posix_fadvise=yes
13967+
else
13968+
echo "$as_me: failed program was:" >&5
13969+
sed 's/^/| /' conftest.$ac_ext >&5
13970+
13971+
ac_cv_have_decl_posix_fadvise=no
13972+
fi
13973+
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
13974+
fi
13975+
echo "$as_me:$LINENO: result: $ac_cv_have_decl_posix_fadvise" >&5
13976+
echo "${ECHO_T}$ac_cv_have_decl_posix_fadvise" >&6
13977+
if test $ac_cv_have_decl_posix_fadvise = yes; then
13978+
13979+
cat >>confdefs.h <<_ACEOF
13980+
#define HAVE_DECL_POSIX_FADVISE 1
13981+
_ACEOF
13982+
13983+
13984+
else
13985+
cat >>confdefs.h <<_ACEOF
13986+
#define HAVE_DECL_POSIX_FADVISE 0
13987+
_ACEOF
13988+
13989+
13990+
fi
13991+
13992+
1392013993

1392113994
HAVE_IPV6=no
1392213995
echo "$as_me:$LINENO: checking for struct sockaddr_in6" >&5

configure.in

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $PostgreSQL: pgsql/configure.in,v 1.466 2006/06/07 22:24:43 momjian Exp $
2+
dnl $PostgreSQL: pgsql/configure.in,v 1.467 2006/06/18 18:30:20 tgl Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -864,6 +864,7 @@ PGAC_FUNC_GETTIMEOFDAY_1ARG
864864
AC_CHECK_FUNCS([cbrt dlopen fcvt fdatasync getpeereid memmove poll pstat readlink setproctitle setsid sigprocmask symlink sysconf towlower utime utimes waitpid wcstombs])
865865

866866
AC_CHECK_DECLS(fdatasync, [], [], [#include <unistd.h>])
867+
AC_CHECK_DECLS(posix_fadvise, [], [], [#include <fcntl.h>])
867868

868869
HAVE_IPV6=no
869870
AC_CHECK_TYPE([struct sockaddr_in6],

src/backend/access/transam/xlog.c

+7-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.239 2006/06/16 04:11:48 momjian Exp $
10+
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.240 2006/06/18 18:30:20 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -2147,11 +2147,13 @@ XLogFileClose(void)
21472147
{
21482148
Assert(openLogFile >= 0);
21492149

2150-
#ifdef POSIX_FADV_DONTNEED
2150+
#if defined(HAVE_DECL_POSIX_FADVISE) && defined(POSIX_FADV_DONTNEED)
21512151
/*
2152-
* WAL caches will not be accessed in the future, so we advise OS to
2153-
* free them. But we will not do so if WAL archiving is active,
2154-
* because archivers might use the caches to read the WAL segment.
2152+
* WAL segment files will not be re-read in normal operation, so we advise
2153+
* OS to release any cached pages. But do not do so if WAL archiving is
2154+
* active, because archiver process could use the cache to read the WAL
2155+
* segment.
2156+
*
21552157
* While O_DIRECT works for O_SYNC, posix_fadvise() works for fsync()
21562158
* and O_SYNC, and some platforms only have posix_fadvise().
21572159
*/

src/include/pg_config.h.in

+4
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@
7676
don't. */
7777
#undef HAVE_DECL_F_FULLFSYNC
7878

79+
/* Define to 1 if you have the declaration of `posix_fadvise', and to 0 if you
80+
don't. */
81+
#undef HAVE_DECL_POSIX_FADVISE
82+
7983
/* Define to 1 if you have the declaration of `snprintf', and to 0 if you
8084
don't. */
8185
#undef HAVE_DECL_SNPRINTF

0 commit comments

Comments
 (0)