diff options
Diffstat (limited to 'winsup/cygwin/fhandler.cc')
-rw-r--r-- | winsup/cygwin/fhandler.cc | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index ae5edcb62..00e987587 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -31,7 +31,6 @@ details. */ #include <winioctl.h> #include <ntdef.h> #include "ntdll.h" -#include "mmap_helper.h" static NO_COPY const int CHUNK_SIZE = 1024; /* Used for crlf conversions */ @@ -224,8 +223,10 @@ fhandler_base::raw_read (void *ptr, size_t& ulen) HANDLE h = NULL; /* grumble */ int prio = 0; /* ditto */ + int try_noreserve = 1; DWORD len = ulen; +retry: ulen = (size_t) -1; if (read_state) { @@ -234,7 +235,7 @@ fhandler_base::raw_read (void *ptr, size_t& ulen) SetThreadPriority (h, THREAD_PRIORITY_TIME_CRITICAL); signal_read_state (1); } - BOOL res = mmReadFile (get_handle (), ptr, len, (DWORD *) &ulen, 0); + BOOL res = ReadFile (get_handle (), ptr, len, (DWORD *) &ulen, 0); if (read_state) { signal_read_state (1); @@ -260,6 +261,19 @@ fhandler_base::raw_read (void *ptr, size_t& ulen) bytes_read = 0; break; } + if (try_noreserve) + { + try_noreserve = 0; + switch (mmap_is_attached_or_noreserve (ptr, len)) + { + case MMAP_NORESERVE_COMMITED: + goto retry; + case MMAP_RAISE_SIGBUS: + raise(SIGBUS); + case MMAP_NONE: + break; + } + } /*FALLTHRU*/ case ERROR_INVALID_FUNCTION: case ERROR_INVALID_PARAMETER: |