1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-31 17:02:12 +03:00

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.
This commit is contained in:
Tom Lane
2004-02-23 23:03:43 +00:00
parent 95a6dbf12b
commit 6b534f3c33
6 changed files with 138 additions and 41 deletions

View File

@@ -3,16 +3,16 @@
* it requires a Window handle which prevents it from working when invoked
* as a service.
*
* $Header: /cvsroot/pgsql/src/port/Attic/copydir.c,v 1.5 2003/09/10 20:12:01 tgl Exp $
* $Header: /cvsroot/pgsql/src/port/Attic/copydir.c,v 1.5.2.1 2004/02/23 23:03:43 tgl Exp $
*/
#include "postgres.h"
#include "storage/fd.h"
#undef mkdir /* no reason to use that macro because we
* ignore the 2nd arg */
#include <dirent.h>
/*
* copydir: copy a directory (we only need to go one level deep)
@@ -37,7 +37,7 @@ copydir(char *fromdir, char *todir)
errmsg("could not create directory \"%s\": %m", todir)));
return -1;
}
xldir = opendir(fromdir);
xldir = AllocateDir(fromdir);
if (xldir == NULL)
{
ereport(WARNING,
@@ -55,11 +55,11 @@ copydir(char *fromdir, char *todir)
ereport(WARNING,
(errcode_for_file_access(),
errmsg("could not copy file \"%s\": %m", fromfl)));
closedir(xldir);
FreeDir(xldir);
return -1;
}
}
closedir(xldir);
FreeDir(xldir);
return 0;
}