Skip to content

fix asyncnet SSL on windows #25035

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions lib/pure/asyncnet.nim
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ type
domain: Domain
sockType: SockType
protocol: Protocol
writers, readers: seq[Future[bool]] # workaround #25034
AsyncSocket* = ref AsyncSocketDesc

proc newAsyncSocket*(fd: AsyncFD, domain: Domain = AF_INET,
Expand Down Expand Up @@ -249,15 +250,23 @@ when defineSsl:
let retFut = newFuture[bool]("asyncnet.handleSslFailure")
case sslError
of SSL_ERROR_WANT_WRITE, SSL_ERROR_WANT_CONNECT, SSL_ERROR_WANT_ACCEPT:
addWrite(socket.fd.AsyncFD, proc (sock: AsyncFD): bool =
retFut.complete(true)
return true
)
socket.writers.add retFut
if socket.writers.len == 1:
addWrite(socket.fd.AsyncFD, proc (sock: AsyncFD): bool =
for f in socket.writers:
f.complete(true)
socket.writers.setLen 0
return true
)
of SSL_ERROR_WANT_READ:
addRead(socket.fd.AsyncFD, proc (sock: AsyncFD): bool =
retFut.complete(true)
return true
)
socket.readers.add retFut
if socket.readers.len == 1:
addRead(socket.fd.AsyncFD, proc (sock: AsyncFD): bool =
for f in socket.readers:
f.complete(true)
socket.readers.setLen 0
return true
)
of SSL_ERROR_SYSCALL:
assert flags.isDisconnectionError(osLastError())
retFut.complete(false)
Expand Down