Merge pull request #4836 from cheatfate/upcoming_tpolltimeouts
Fix upcoming to pass tpolltimeouts
This commit is contained in:
commit
2737c98ac4
1 changed files with 31 additions and 30 deletions
|
|
@ -243,43 +243,44 @@ when defined(windows) or defined(nimdoc):
|
||||||
if at == -1: winlean.INFINITE
|
if at == -1: winlean.INFINITE
|
||||||
else: at.int32
|
else: at.int32
|
||||||
|
|
||||||
var lpNumberOfBytesTransferred: Dword
|
if p.handles.len != 0:
|
||||||
var lpCompletionKey: ULONG_PTR
|
var lpNumberOfBytesTransferred: Dword
|
||||||
var customOverlapped: PCustomOverlapped
|
var lpCompletionKey: ULONG_PTR
|
||||||
let res = getQueuedCompletionStatus(p.ioPort,
|
var customOverlapped: PCustomOverlapped
|
||||||
addr lpNumberOfBytesTransferred, addr lpCompletionKey,
|
let res = getQueuedCompletionStatus(p.ioPort,
|
||||||
cast[ptr POVERLAPPED](addr customOverlapped), llTimeout).bool
|
addr lpNumberOfBytesTransferred, addr lpCompletionKey,
|
||||||
|
cast[ptr POVERLAPPED](addr customOverlapped), llTimeout).bool
|
||||||
|
|
||||||
# http://stackoverflow.com/a/12277264/492186
|
# http://stackoverflow.com/a/12277264/492186
|
||||||
# TODO: http://www.serverframework.com/handling-multiple-pending-socket-read-and-write-operations.html
|
# TODO: http://www.serverframework.com/handling-multiple-pending-socket-read-and-write-operations.html
|
||||||
if res:
|
if res:
|
||||||
# This is useful for ensuring the reliability of the overlapped struct.
|
# This is useful for ensuring the reliability of the overlapped struct.
|
||||||
assert customOverlapped.data.fd == lpCompletionKey.AsyncFD
|
|
||||||
|
|
||||||
customOverlapped.data.cb(customOverlapped.data.fd,
|
|
||||||
lpNumberOfBytesTransferred, OSErrorCode(-1))
|
|
||||||
|
|
||||||
# If cell.data != nil, then system.protect(rawEnv(cb)) was called,
|
|
||||||
# so we need to dispose our `cb` environment, because it is not needed
|
|
||||||
# anymore.
|
|
||||||
if customOverlapped.data.cell.data != nil:
|
|
||||||
system.dispose(customOverlapped.data.cell)
|
|
||||||
|
|
||||||
GC_unref(customOverlapped)
|
|
||||||
else:
|
|
||||||
let errCode = osLastError()
|
|
||||||
if customOverlapped != nil:
|
|
||||||
assert customOverlapped.data.fd == lpCompletionKey.AsyncFD
|
assert customOverlapped.data.fd == lpCompletionKey.AsyncFD
|
||||||
|
|
||||||
customOverlapped.data.cb(customOverlapped.data.fd,
|
customOverlapped.data.cb(customOverlapped.data.fd,
|
||||||
lpNumberOfBytesTransferred, errCode)
|
lpNumberOfBytesTransferred, OSErrorCode(-1))
|
||||||
|
|
||||||
|
# If cell.data != nil, then system.protect(rawEnv(cb)) was called,
|
||||||
|
# so we need to dispose our `cb` environment, because it is not needed
|
||||||
|
# anymore.
|
||||||
if customOverlapped.data.cell.data != nil:
|
if customOverlapped.data.cell.data != nil:
|
||||||
system.dispose(customOverlapped.data.cell)
|
system.dispose(customOverlapped.data.cell)
|
||||||
|
|
||||||
GC_unref(customOverlapped)
|
GC_unref(customOverlapped)
|
||||||
else:
|
else:
|
||||||
if errCode.int32 == WAIT_TIMEOUT:
|
let errCode = osLastError()
|
||||||
# Timed out
|
if customOverlapped != nil:
|
||||||
discard
|
assert customOverlapped.data.fd == lpCompletionKey.AsyncFD
|
||||||
else: raiseOSError(errCode)
|
customOverlapped.data.cb(customOverlapped.data.fd,
|
||||||
|
lpNumberOfBytesTransferred, errCode)
|
||||||
|
if customOverlapped.data.cell.data != nil:
|
||||||
|
system.dispose(customOverlapped.data.cell)
|
||||||
|
GC_unref(customOverlapped)
|
||||||
|
else:
|
||||||
|
if errCode.int32 == WAIT_TIMEOUT:
|
||||||
|
# Timed out
|
||||||
|
discard
|
||||||
|
else: raiseOSError(errCode)
|
||||||
|
|
||||||
# Timer processing.
|
# Timer processing.
|
||||||
processTimers(p)
|
processTimers(p)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue