summaryrefslogtreecommitdiff
path: root/src/backend/access/transam/slru.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-02-23 23:03:43 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-02-23 23:03:43 +0000
commit6b534f3c3394f86ec79cd764a0413e56af26773a (patch)
tree5a2d17ab8d1f82dc968c09c1091ff7eda18c2b93 /src/backend/access/transam/slru.c
parent95a6dbf12b2aa7261cd6f13f41cc8de8a693ee75 (diff)
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.
Diffstat (limited to 'src/backend/access/transam/slru.c')
-rw-r--r--src/backend/access/transam/slru.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index f0ca7ffb76a..dfa1fba8870 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -6,15 +6,13 @@
* 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/slru.c,v 1.7 2003/09/25 06:57:57 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/slru.c,v 1.7.2.1 2004/02/23 23:03:43 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include <fcntl.h>
-#include <dirent.h>
-#include <errno.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -872,7 +870,7 @@ SlruScanDirectory(SlruCtl ctl, int cutoffPage, bool doDeletions)
int segpage;
char path[MAXPGPATH];
- cldir = opendir(ctl->Dir);
+ cldir = AllocateDir(ctl->Dir);
if (cldir == NULL)
ereport(ERROR,
(errcode_for_file_access(),
@@ -905,7 +903,7 @@ SlruScanDirectory(SlruCtl ctl, int cutoffPage, bool doDeletions)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not read directory \"%s\": %m", ctl->Dir)));
- closedir(cldir);
+ FreeDir(cldir);
return found;
}