From 6b534f3c3394f86ec79cd764a0413e56af26773a Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 23 Feb 2004 23:03:43 +0000 Subject: Replace opendir/closedir calls throughout the backend with AllocateDir and FreeDir routines modeled on the existing AllocateFile/FreeFile. Like the latter, these routines will avoid failing on EMFILE/ENFILE conditions whenever possible, and will prevent leakage of directory descriptors if an elog() occurs while one is open. Also, reduce PANIC to ERROR in MoveOfflineLogs() --- this is not critical code and there is no reason to force a DB restart on failure. All per recent trouble report from Olivier Hubaut. --- src/backend/access/transam/xlog.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/backend/access/transam/xlog.c') diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index f9c202f7023..8eb154f7bab 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.125 2003/09/27 18:16:35 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.125.2.1 2004/02/23 23:03:43 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -17,10 +17,8 @@ #include #include #include -#include #include #include -#include #include "access/clog.h" #include "access/transam.h" @@ -1617,9 +1615,9 @@ MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr) XLByteToPrevSeg(endptr, endlogId, endlogSeg); - xldir = opendir(XLogDir); + xldir = AllocateDir(XLogDir); if (xldir == NULL) - ereport(PANIC, + ereport(ERROR, (errcode_for_file_access(), errmsg("could not open transaction log directory \"%s\": %m", XLogDir))); @@ -1670,11 +1668,11 @@ MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr) errno = 0; } if (errno) - ereport(PANIC, + ereport(ERROR, (errcode_for_file_access(), errmsg("could not read transaction log directory \"%s\": %m", XLogDir))); - closedir(xldir); + FreeDir(xldir); } /* -- cgit v1.2.3