aboutsummaryrefslogtreecommitdiff
path: root/contrib/dbsize/dbsize.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 /contrib/dbsize/dbsize.c
parent95a6dbf12b2aa7261cd6f13f41cc8de8a693ee75 (diff)
downloadpostgresql-6b534f3c3394f86ec79cd764a0413e56af26773a.tar.gz
postgresql-6b534f3c3394f86ec79cd764a0413e56af26773a.zip
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 'contrib/dbsize/dbsize.c')
-rw-r--r--contrib/dbsize/dbsize.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/contrib/dbsize/dbsize.c b/contrib/dbsize/dbsize.c
index 0037c14e706..7b976822371 100644
--- a/contrib/dbsize/dbsize.c
+++ b/contrib/dbsize/dbsize.c
@@ -1,16 +1,15 @@
#include "postgres.h"
#include <sys/types.h>
-#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>
-#include <errno.h>
#include "access/heapam.h"
#include "catalog/catalog.h"
#include "catalog/namespace.h"
#include "commands/dbcommands.h"
#include "fmgr.h"
+#include "storage/fd.h"
#include "utils/builtins.h"
@@ -58,7 +57,7 @@ database_size(PG_FUNCTION_ARGS)
dbpath = GetDatabasePath(dbid);
- dirdesc = opendir(dbpath);
+ dirdesc = AllocateDir(dbpath);
if (!dirdesc)
ereport(ERROR,
(errcode_for_file_access(),
@@ -93,7 +92,7 @@ database_size(PG_FUNCTION_ARGS)
pfree(fullname);
}
- closedir(dirdesc);
+ FreeDir(dirdesc);
PG_RETURN_INT64(totalsize);
}