aboutsummaryrefslogtreecommitdiff
path: root/src/include
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 /src/include
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 'src/include')
-rw-r--r--src/include/storage/fd.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/include/storage/fd.h b/src/include/storage/fd.h
index 537fec5af9d..11226901f13 100644
--- a/src/include/storage/fd.h
+++ b/src/include/storage/fd.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: fd.h,v 1.39.4.1 2004/02/23 20:46:16 tgl Exp $
+ * $Id: fd.h,v 1.39.4.2 2004/02/23 23:03:43 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -31,10 +31,16 @@
* use FreeFile, not fclose, to close it. AVOID using stdio for files
* that you intend to hold open for any length of time, since there is
* no way for them to share kernel file descriptors with other files.
+ *
+ * Likewise, use AllocateDir/FreeDir, not opendir/closedir, to allocate
+ * open directories (DIR*).
*/
#ifndef FD_H
#define FD_H
+#include <dirent.h>
+
+
/*
* FileSeek uses the standard UNIX lseek(2) flags.
*/
@@ -65,7 +71,11 @@ extern int FileTruncate(File file, long offset);
/* Operations that allow use of regular stdio --- USE WITH CAUTION */
extern FILE *AllocateFile(char *name, char *mode);
-extern void FreeFile(FILE *);
+extern void FreeFile(FILE *file);
+
+/* Operations to allow use of the <dirent.h> library routines */
+extern DIR *AllocateDir(const char *dirname);
+extern int FreeDir(DIR *dir);
/* If you've really really gotta have a plain kernel FD, use this */
extern int BasicOpenFile(FileName fileName, int fileFlags, int fileMode);