summaryrefslogtreecommitdiff
path: root/src/port/copydir.c
diff options
context:
space:
mode:
authorTom Lane2004-02-23 23:03:10 +0000
committerTom Lane2004-02-23 23:03:10 +0000
commit7a57a672788ff04723544a650e33502429ad8581 (patch)
tree10f74dc64f145d55dc65f6df405154cbccd86aef /src/port/copydir.c
parent4f571319d362735e3efa6293737c5e12181f3477 (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/port/copydir.c')
-rw-r--r--src/port/copydir.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/port/copydir.c b/src/port/copydir.c
index 64a8407a7f8..7d33d14c82b 100644
--- a/src/port/copydir.c
+++ b/src/port/copydir.c
@@ -11,18 +11,18 @@
* as a service.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/port/copydir.c,v 1.7 2003/11/29 19:52:13 pgsql Exp $
+ * $PostgreSQL: pgsql/src/port/copydir.c,v 1.8 2004/02/23 23:03:10 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)
@@ -47,7 +47,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,
@@ -65,11 +65,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;
}