From 7a57a672788ff04723544a650e33502429ad8581 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 23 Feb 2004 23:03:10 +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. --- contrib/dbsize/dbsize.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'contrib/dbsize/dbsize.c') 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 -#include #include #include -#include #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); } -- cgit v1.2.3