Only run the test for the fixed version of poll(...)

This commit is contained in:
Kay Zheng 2015-04-17 22:40:53 +08:00
commit 3125058b6a

View file

@ -16,7 +16,10 @@ const
testPort = Port(17357) testPort = Port(17357)
proc createListenSocket(host: string, port: Port): TAsyncFD = when defined(windows) or defined(nimdoc):
discard
else:
proc createListenSocket(host: string, port: Port): TAsyncFD =
result = newAsyncRawSocket() result = newAsyncRawSocket()
SocketHandle(result).setSockOptInt(SOL_SOCKET, SO_REUSEADDR, 1) SocketHandle(result).setSockOptInt(SOL_SOCKET, SO_REUSEADDR, 1)
@ -31,7 +34,7 @@ proc createListenSocket(host: string, port: Port): TAsyncFD =
raiseOSError(osLastError()) raiseOSError(osLastError())
proc testAsyncSend() {.async.} = proc testAsyncSend() {.async.} =
var var
ls = createListenSocket(testHost, testPort) ls = createListenSocket(testHost, testPort)
s = newAsyncSocket() s = newAsyncSocket()
@ -48,15 +51,15 @@ proc testAsyncSend() {.async.} =
SocketHandle(ps).close() SocketHandle(ps).close()
# The bug was, when the poll function handled EvError for us, # The bug was, when the poll function handled EvError for us,
# our callbacks may never get executed, thus making the event # our callbacks may never get executed, thus making the event
# loop block indefinitely. This is a timer to keep everything # loop block indefinitely. This is a timer to keep everything
# rolling. 400 ms is an arbitrary value, should be enough though. # rolling. 400 ms is an arbitrary value, should be enough though.
proc timer() {.async.} = proc timer() {.async.} =
await sleepAsync(400) await sleepAsync(400)
echo("Timer expired.") echo("Timer expired.")
quit(2) quit(2)
asyncCheck(testAsyncSend()) asyncCheck(testAsyncSend())
waitFor(timer()) waitFor(timer())