git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 80e05a0)
Handle ReadFile() EOF correctly on Windows.
2019年11月20日 04:52:15 +0000 (17:52 +1300)
2019年11月20日 05:29:37 +0000 (18:29 +1300)
When ReadFile() encounters the end of a file while reading from
a synchronous handle with an offset provided via OVERLAPPED, it
reports an error instead of returning 0. By not handling that
(undocumented) result correctly, we caused some noisy LOG
messages about an unknown error code. Repair.

Back-patch to 12, where we started using pread()/ReadFile() with
an offset.

Reported-by: ZhenHua Cai, Amit Kapila
Diagnosed-by: Juan Jose Santamaria Flecha
Tested-by: Amit Kapila
Discussion: https://postgr.es/m/CAA4eK1LK3%2BWRtpz68TiRdpHwxxWm%3D%2Bt1BMf-G68hhQsAQ41PZg%40mail.gmail.com


diff --git a/src/port/pread.c b/src/port/pread.c
index a84859e8126312a51af89be80eff71714d2bf2d0..464cd2e865586425c5bb2467d75ab24ac390b0bb 100644 (file)
--- a/src/port/pread.c
+++ b/src/port/pread.c
@@ -41,6 +41,9 @@ pg_pread(int fd, void *buf, size_t size, off_t offset)
overlapped.Offset = offset;
if (!ReadFile(handle, buf, size, &result, &overlapped))
{
+ if (GetLastError() == ERROR_HANDLE_EOF)
+ return 0;
+
_dosmaperr(GetLastError());
return -1;
}
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /