1
0
mirror of https://github.com/janet-lang/janet synced 2025-01-13 00:50:26 +00:00

Merge pull request #908 from ishehadeh/master

Windows: Fix `ev/read` hanging when called on stream from `os/open`
This commit is contained in:
Calvin Rose 2022-01-08 11:26:48 -06:00 committed by GitHub
commit ab53208f47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2219,6 +2219,10 @@ JanetAsyncStatus ev_machine_read(JanetListenerState *s, JanetAsyncEvent event) {
} else
#endif
{
// Some handles (not all) read from the offset in lopOverlapped
// if its not set before calling `ReadFile` these streams will always read from offset 0
state->overlapped.Offset = (DWORD) state->bytes_read;
status = ReadFile(s->stream->handle, state->chunk_buf, chunk_size, NULL, &state->overlapped);
if (!status && (ERROR_IO_PENDING != WSAGetLastError())) {
if (WSAGetLastError() == ERROR_BROKEN_PIPE) {