aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/pg_archivecleanup/pg_archivecleanup.c16
-rw-r--r--contrib/pg_standby/pg_standby.c17
-rw-r--r--contrib/pg_upgrade/file.c14
3 files changed, 41 insertions, 6 deletions
diff --git a/contrib/pg_archivecleanup/pg_archivecleanup.c b/contrib/pg_archivecleanup/pg_archivecleanup.c
index 400968ce399..84d80f215c5 100644
--- a/contrib/pg_archivecleanup/pg_archivecleanup.c
+++ b/contrib/pg_archivecleanup/pg_archivecleanup.c
@@ -98,7 +98,7 @@ CleanupPriorWALFiles(void)
if ((xldir = opendir(archiveLocation)) != NULL)
{
- while ((xlde = readdir(xldir)) != NULL)
+ while (errno = 0, (xlde = readdir(xldir)) != NULL)
{
/*
* We ignore the timeline part of the XLOG segment identifiers in
@@ -132,7 +132,19 @@ CleanupPriorWALFiles(void)
}
}
}
- closedir(xldir);
+
+#ifdef WIN32
+ /* Bug in old Mingw dirent.c; fixed in mingw-runtime-3.2, 2003-10-10 */
+ if (GetLastError() == ERROR_NO_MORE_FILES)
+ errno = 0;
+#endif
+
+ if (errno)
+ fprintf(stderr, "%s: could not read archive location \"%s\": %s\n",
+ progname, archiveLocation, strerror(errno));
+ if (closedir(xldir))
+ fprintf(stderr, "%s: could not close archive location \"%s\": %s\n",
+ progname, archiveLocation, strerror(errno));
}
else
fprintf(stderr, "%s: could not open archive location \"%s\": %s\n",
diff --git a/contrib/pg_standby/pg_standby.c b/contrib/pg_standby/pg_standby.c
index e20fbbb625a..a99b94ef1b5 100644
--- a/contrib/pg_standby/pg_standby.c
+++ b/contrib/pg_standby/pg_standby.c
@@ -256,7 +256,7 @@ CustomizableCleanupPriorWALFiles(void)
*/
if ((xldir = opendir(archiveLocation)) != NULL)
{
- while ((xlde = readdir(xldir)) != NULL)
+ while (errno = 0, (xlde = readdir(xldir)) != NULL)
{
/*
* We ignore the timeline part of the XLOG segment identifiers
@@ -294,6 +294,16 @@ CustomizableCleanupPriorWALFiles(void)
}
}
}
+
+#ifdef WIN32
+ /* Bug in old Mingw dirent.c; fixed in mingw-runtime-3.2, 2003-10-10 */
+ if (GetLastError() == ERROR_NO_MORE_FILES)
+ errno = 0;
+#endif
+
+ if (errno)
+ fprintf(stderr, "%s: could not read archive location \"%s\": %s\n",
+ progname, archiveLocation, strerror(errno));
if (debug)
fprintf(stderr, "\n");
}
@@ -301,7 +311,10 @@ CustomizableCleanupPriorWALFiles(void)
fprintf(stderr, "%s: could not open archive location \"%s\": %s\n",
progname, archiveLocation, strerror(errno));
- closedir(xldir);
+ if (closedir(xldir))
+ fprintf(stderr, "%s: could not close archive location \"%s\": %s\n",
+ progname, archiveLocation, strerror(errno));
+
fflush(stderr);
}
}
diff --git a/contrib/pg_upgrade/file.c b/contrib/pg_upgrade/file.c
index 8fdc86d7d47..de23dedbf2b 100644
--- a/contrib/pg_upgrade/file.c
+++ b/contrib/pg_upgrade/file.c
@@ -291,7 +291,7 @@ pg_scandir_internal(const char *dirname,
*namelist = NULL;
- while ((direntry = readdir(dirdesc)) != NULL)
+ while (errno = 0, (direntry = readdir(dirdesc)) != NULL)
{
/* Invoke the selector function to see if the direntry matches */
if (!selector || (*selector) (direntry))
@@ -324,7 +324,17 @@ pg_scandir_internal(const char *dirname,
}
}
- closedir(dirdesc);
+#ifdef WIN32
+ /* Bug in old Mingw dirent.c; fixed in mingw-runtime-3.2, 2003-10-10 */
+ if (GetLastError() == ERROR_NO_MORE_FILES)
+ errno = 0;
+#endif
+
+ if (errno)
+ pg_log(PG_FATAL, "could not read directory \"%s\": %s\n", dirname, getErrorText(errno));
+
+ if (closedir(dirdesc))
+ pg_log(PG_FATAL, "could not close directory \"%s\": %s\n", dirname, getErrorText(errno));
return count;
}