diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-02-23 23:03:10 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-02-23 23:03:10 +0000 |
commit | 7a57a672788ff04723544a650e33502429ad8581 (patch) | |
tree | 10f74dc64f145d55dc65f6df405154cbccd86aef /src/backend/access/transam/slru.c | |
parent | 4f571319d362735e3efa6293737c5e12181f3477 (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.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c index aac93a60a3f..a12fe885563 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 * - * $PostgreSQL: pgsql/src/backend/access/transam/slru.c,v 1.12 2004/02/17 03:45:17 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/slru.c,v 1.13 2004/02/23 23:03:10 tgl Exp $ * *------------------------------------------------------------------------- */ #include "postgres.h" #include <fcntl.h> -#include <dirent.h> -#include <errno.h> #include <sys/stat.h> #include <unistd.h> @@ -888,7 +886,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(), @@ -927,7 +925,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; } |