From 1e8ae136407f2aedd07cc748589f46087b98b950 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 18 Jun 2006 18:30:21 +0000 Subject: Don't try to call posix_fadvise() unless 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. --- src/backend/access/transam/xlog.c | 12 +++++++----- src/include/pg_config.h.in | 4 ++++ 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 57a8d1833d8..85618fcf01c 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -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(). */ diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index 5ccfbfefd28..82ccde63c1c 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -76,6 +76,10 @@ 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 -- cgit v1.2.3