summary refs log tree commit diff stats
path: root/lib/windows
diff options
context:
space:
mode:
authorcheatfate <ka@hardcore.kiev.ua>2016-05-12 21:11:42 +0300
committercheatfate <ka@hardcore.kiev.ua>2016-05-12 21:11:42 +0300
commit6fa6fdeb34c1c34e0aa0734e611e95b7fd2c48f3 (patch)
tree5bc1e663bd455c9395e1531059298698a19de6c0 /lib/windows
parent6e6c15081d8e660ebd4e7111c69962e4da2d2aa5 (diff)
downloadNim-6fa6fdeb34c1c34e0aa0734e611e95b7fd2c48f3.tar.gz
Resolve bugs based on unreliable `bytesReceived` value.
Diffstat (limited to 'lib/windows')
-rw-r--r--lib/windows/winlean.nim7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/windows/winlean.nim b/lib/windows/winlean.nim
index de9898dce..8ad3faf41 100644
--- a/lib/windows/winlean.nim
+++ b/lib/windows/winlean.nim
@@ -759,6 +759,7 @@ const
   WSAENETRESET* = 10052
   WSAETIMEDOUT* = 10060
   ERROR_NETNAME_DELETED* = 64
+  STATUS_PENDING* = 0x103
 
 proc createIoCompletionPort*(FileHandle: Handle, ExistingCompletionPort: Handle,
                              CompletionKey: ULONG_PTR,
@@ -775,6 +776,12 @@ proc getOverlappedResult*(hFile: Handle, lpOverlapped: POVERLAPPED,
               lpNumberOfBytesTransferred: var DWORD, bWait: WINBOOL): WINBOOL{.
     stdcall, dynlib: "kernel32", importc: "GetOverlappedResult".}
 
+# this is copy of HasOverlappedIoCompleted() macro from <winbase.h>
+# because we have declared own OVERLAPPED structure with member names not
+# compatible with original names.
+template hasOverlappedIoCompleted*(lpOverlapped): bool =
+  (cast[uint](lpOverlapped.internal) != STATUS_PENDING)
+
 const
  IOC_OUT* = 0x40000000
  IOC_IN*  = 0x80000000