improve-eacces-handling.patch
text/x-patch
Filename: improve-eacces-handling.patch
Type: text/x-patch
Part: 0
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/port/open.c | 13 | 5 |
diff --git a/src/port/open.c b/src/port/open.c
index 51652762a1..2196cbc992 100644
--- a/src/port/open.c
+++ b/src/port/open.c
@@ -144,11 +144,19 @@ pgwin32_open(const char *fileName, int fileFlags,...)
*/
if (err == ERROR_ACCESS_DENIED)
{
- if (loops < 10)
- {
- pg_usleep(100000);
- loops++;
- continue;
+ /*
+ * We don't want to retry fopen() with a directory,
+ * which is known to fail with the same ERROR_ACCESS_DENIED error
+ * (Windows NT status code STATUS_FILE_IS_A_DIRECTORY).
+ */
+ struct stat st;
+ if (stat(fileName, &st) != 0 || !S_ISDIR(st.st_mode)) {
+ if (loops < 10)
+ {
+ pg_usleep(100000);
+ loops++;
+ continue;
+ }
}
}