diff options
Diffstat (limited to 'src/backend/storage/file/fd.c')
-rw-r--r-- | src/backend/storage/file/fd.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c index 387092724d2..107907daa8c 100644 --- a/src/backend/storage/file/fd.c +++ b/src/backend/storage/file/fd.c @@ -108,9 +108,15 @@ static int max_safe_fds = 32; /* default if not changed */ /* Debugging.... */ #ifdef FDDEBUG -#define DO_DB(A) A +#define DO_DB(A) \ + do { \ + int _do_db_save_errno = errno; \ + A; \ + errno = _do_db_save_errno; \ + } while (0) #else -#define DO_DB(A) /* A */ +#define DO_DB(A) \ + ((void) 0) #endif #define VFD_CLOSED (-1) @@ -664,7 +670,7 @@ LruInsert(File file) if (vfdP->fd < 0) { DO_DB(elog(LOG, "RE_OPEN FAILED: %d", errno)); - return vfdP->fd; + return -1; } else { @@ -715,7 +721,7 @@ AllocateVfd(void) Index i; File file; - DO_DB(elog(LOG, "AllocateVfd. Size %lu", SizeVfdCache)); + DO_DB(elog(LOG, "AllocateVfd. Size %lu", (unsigned long) SizeVfdCache)); Assert(SizeVfdCache > 0); /* InitFileAccess not called? */ @@ -872,8 +878,11 @@ PathNameOpenFile(FileName fileName, int fileFlags, int fileMode) if (vfdP->fd < 0) { + int save_errno = errno; + FreeVfd(file); free(fnamecopy); + errno = save_errno; return -1; } ++nfile; |