Fix cancellation race when connect() call is getting cancelled. (#101)

This commit is contained in:
Eugene Kabanov 2020-06-04 13:07:52 +03:00 committed by GitHub
parent bce0f878d1
commit d6d0084333
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -722,7 +722,8 @@ when defined(windows):
GC_unref(ovl)
proc cancel(udata: pointer) {.gcsafe.} =
sock.closeSocket()
if not(retFuture.finished()):
sock.closeSocket()
povl = RefCustomOverlapped()
GC_ref(povl)
@ -1250,7 +1251,8 @@ else:
retFuture.complete(transp)
proc cancel(udata: pointer) {.gcsafe.} =
closeSocket(sock)
if not(retFuture.finished()):
closeSocket(sock)
while true:
var res = posix.connect(SocketHandle(sock),