summaryrefslogtreecommitdiff
path: root/src/backend/postmaster
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-06-19 21:34:03 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-06-19 21:34:03 +0000
commit3f749924f82efd5b2f4b424f6c69a89a2959e4b3 (patch)
tree3bd4c6588dc45f0b88f394e0dee85f201f54d4d0 /src/backend/postmaster
parente26b0abda3919448d5ccbcaac0415010022864b7 (diff)
downloadpostgresql-3f749924f82efd5b2f4b424f6c69a89a2959e4b3.tar.gz
Simplify uses of readdir() by creating a function ReadDir() that
includes error checking and an appropriate ereport(ERROR) message. This gets rid of rather tedious and error-prone manipulation of errno, as well as a Windows-specific bug workaround, at more than a dozen call sites. After an idea in a recent patch by Heikki Linnakangas.
Diffstat (limited to 'src/backend/postmaster')
-rw-r--r--src/backend/postmaster/pgarch.c21
1 files changed, 2 insertions, 19 deletions
diff --git a/src/backend/postmaster/pgarch.c b/src/backend/postmaster/pgarch.c
index fc2d9ce729..e5eecb2dbc 100644
--- a/src/backend/postmaster/pgarch.c
+++ b/src/backend/postmaster/pgarch.c
@@ -19,7 +19,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/postmaster/pgarch.c,v 1.15 2005/03/10 07:14:03 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/pgarch.c,v 1.16 2005/06/19 21:34:01 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -510,8 +510,7 @@ pgarch_readyXlog(char *xlog)
errmsg("could not open archive status directory \"%s\": %m",
XLogArchiveStatusDir)));
- errno = 0;
- while ((rlde = readdir(rldir)) != NULL)
+ while ((rlde = ReadDir(rldir, XLogArchiveStatusDir)) != NULL)
{
int basenamelen = (int) strlen(rlde->d_name) - 6;
@@ -531,23 +530,7 @@ pgarch_readyXlog(char *xlog)
strcpy(newxlog, rlde->d_name);
}
}
-
- errno = 0;
}
-#ifdef WIN32
-
- /*
- * This fix is in mingw cvs (runtime/mingwex/dirent.c rev 1.4), but
- * not in released version
- */
- if (GetLastError() == ERROR_NO_MORE_FILES)
- errno = 0;
-#endif
- if (errno)
- ereport(ERROR,
- (errcode_for_file_access(),
- errmsg("could not read archive status directory \"%s\": %m",
- XLogArchiveStatusDir)));
FreeDir(rldir);
if (found)