From 30a0c77d19e4386c4f70a848fd80796b79658d30 Mon Sep 17 00:00:00 2001 From: Michael Camilleri Date: Fri, 7 Jan 2022 13:28:22 +0900 Subject: [PATCH 1/2] Fix 'redefs' typo in test suite --- test/suite0000.janet | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/suite0000.janet b/test/suite0000.janet index d3a46400..0dd96636 100644 --- a/test/suite0000.janet +++ b/test/suite0000.janet @@ -315,9 +315,9 @@ (assert (= 1 (staticdef2-inc)) "after redefinition with :redef false") (def dynamicdef2 0) (defn dynamicdef2-inc [] (+ 1 dynamicdef2)) -(assert (= 1 (dynamicdef2-inc)) "before redefinition with dyn :redefs") +(assert (= 1 (dynamicdef2-inc)) "before redefinition with dyn :redef") (def dynamicdef2 1) -(assert (= 2 (dynamicdef2-inc)) "after redefinition with dyn :redefs") +(assert (= 2 (dynamicdef2-inc)) "after redefinition with dyn :redef") (setdyn :redef nil) # Denormal tables and structs From 60378ff941d5c32b09b2056457cd752b07b899d7 Mon Sep 17 00:00:00 2001 From: Ian Shehadeh Date: Fri, 7 Jan 2022 16:32:39 -0500 Subject: [PATCH 2/2] windows: fix ev/read hang when called on fs stream handles returned by CreateFileA and FILE_FLAG_OVERLAPPED support reading from arbitrary offsets. The offset is passed to ReadFile in through the OVERLAPPED structure. Since state->overlapped is zeroed ev_machine_read ReadFile would always read from the start of the file and never finish This commit changes ev_machine_read to update the offset to the number of bytes read before calling ReadFile. --- src/core/ev.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/ev.c b/src/core/ev.c index d37cb4f6..c47cf359 100644 --- a/src/core/ev.c +++ b/src/core/ev.c @@ -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) {