summary refs log tree commit diff stats
path: root/lib/pure
diff options
context:
space:
mode:
authorKay Zheng <l04m33@gmail.com>2015-04-18 10:27:35 +0800
committerKay Zheng <l04m33@gmail.com>2015-04-18 10:27:35 +0800
commita11a2f0fdb3ecdd995e4fc1a6cb41de4e7fc12f2 (patch)
treeddec51c41b22c38ad7f4aea2d09b07fa4b9620d3 /lib/pure
parent3125058b6ab4bd9c3ad2cb103bb326463af0a7ff (diff)
downloadNim-a11a2f0fdb3ecdd995e4fc1a6cb41de4e7fc12f2.tar.gz
Check for async errors in
Diffstat (limited to 'lib/pure')
-rw-r--r--lib/pure/asyncdispatch.nim14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/pure/asyncdispatch.nim b/lib/pure/asyncdispatch.nim
index 6ed782545..ca5b13c78 100644
--- a/lib/pure/asyncdispatch.nim
+++ b/lib/pure/asyncdispatch.nim
@@ -923,9 +923,17 @@ else:
     var retFuture = newFuture[void]("connect")
 
     proc cb(fd: TAsyncFD): bool =
-      # We have connected.
-      retFuture.complete()
-      return true
+      var ret = SocketHandle(fd).getSockOptInt(cint(SOL_SOCKET), cint(SO_ERROR))
+      if ret == 0:
+          # We have connected.
+          retFuture.complete()
+          return true
+      elif ret == EINTR:
+          # interrupted, keep waiting
+          return false
+      else:
+          retFuture.fail(newException(OSError, osErrorMsg(OSErrorCode(ret))))
+          return true
 
     var aiList = getAddrInfo(address, port, af)
     var success = false