Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6969dee

Browse filesBrowse files
committed
Handle ReadFile() EOF correctly on Windows.
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
1 parent 80e05a0 commit 6969dee
Copy full SHA for 6969dee

File tree

Expand file treeCollapse file tree

1 file changed

+3
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-0
lines changed

‎src/port/pread.c

Copy file name to clipboardExpand all lines: src/port/pread.c
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ pg_pread(int fd, void *buf, size_t size, off_t offset)
4141
overlapped.Offset = offset;
4242
if (!ReadFile(handle, buf, size, &result, &overlapped))
4343
{
44+
if (GetLastError() == ERROR_HANDLE_EOF)
45+
return 0;
46+
4447
_dosmaperr(GetLastError());
4548
return -1;
4649
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.