summary refs log tree commit diff stats
path: root/lib/windows
diff options
context:
space:
mode:
authorDominik Picheta <dominikpicheta@googlemail.com>2016-05-13 13:34:50 +0100
committerDominik Picheta <dominikpicheta@googlemail.com>2016-05-13 13:34:50 +0100
commit373c47ba70f970a76088edcfcc1c018dc61587c4 (patch)
tree3818ba5f11d65139f1dba03fa92d22eceff007c7 /lib/windows
parent746132d6963e8c5dabde19c62a89d22560b820fd (diff)
parent6fa6fdeb34c1c34e0aa0734e611e95b7fd2c48f3 (diff)
downloadNim-373c47ba70f970a76088edcfcc1c018dc61587c4.tar.gz
Merge pull request #4150 from cheatfate/winasync
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