From 6ba9c41763afbea25e1d3985aa4fb971f3c2384a Mon Sep 17 00:00:00 2001 From: nitely Date: Tue, 8 Jul 2025 02:04:09 -0300 Subject: [PATCH 1/3] fix asyncnet SSL on windows --- lib/pure/asyncnet.nim | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/pure/asyncnet.nim b/lib/pure/asyncnet.nim index 4efbbf883491..3f3d7178f5c7 100644 --- a/lib/pure/asyncnet.nim +++ b/lib/pure/asyncnet.nim @@ -130,6 +130,7 @@ type domain: Domain sockType: SockType protocol: Protocol + writers, readers: seq[Future[bool]] AsyncSocket* = ref AsyncSocketDesc proc newAsyncSocket*(fd: AsyncFD, domain: Domain = AF_INET, @@ -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) From 207cde800dd1567056c2bc49fc5e818aa2c09077 Mon Sep 17 00:00:00 2001 From: nitely Date: Tue, 8 Jul 2025 02:11:28 -0300 Subject: [PATCH 2/3] comment --- lib/pure/asyncnet.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pure/asyncnet.nim b/lib/pure/asyncnet.nim index 3f3d7178f5c7..21ff26ca0588 100644 --- a/lib/pure/asyncnet.nim +++ b/lib/pure/asyncnet.nim @@ -130,7 +130,7 @@ type domain: Domain sockType: SockType protocol: Protocol - writers, readers: seq[Future[bool]] + writers, readers: seq[Future[bool]] # workaorund #25034 AsyncSocket* = ref AsyncSocketDesc proc newAsyncSocket*(fd: AsyncFD, domain: Domain = AF_INET, From 3154b97278af0d52f645c461c42191c8345785fc Mon Sep 17 00:00:00 2001 From: nitely Date: Tue, 8 Jul 2025 02:11:59 -0300 Subject: [PATCH 3/3] comment --- lib/pure/asyncnet.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pure/asyncnet.nim b/lib/pure/asyncnet.nim index 21ff26ca0588..3a64207a2400 100644 --- a/lib/pure/asyncnet.nim +++ b/lib/pure/asyncnet.nim @@ -130,7 +130,7 @@ type domain: Domain sockType: SockType protocol: Protocol - writers, readers: seq[Future[bool]] # workaorund #25034 + writers, readers: seq[Future[bool]] # workaround #25034 AsyncSocket* = ref AsyncSocketDesc proc newAsyncSocket*(fd: AsyncFD, domain: Domain = AF_INET,