Skip to content

Commit dc519a5

Browse files
alavissnarimiran
authored andcommitted
asyncnet: don't try to close the socket again [backport] (#15174)
The closed flag isn't a good design by any means, but let's have this working first before I get rid of the flag and potentially create a non-backportable commit. (cherry picked from commit 957bf15)
1 parent acfd1b2 commit dc519a5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/pure/asyncnet.nim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,8 +689,12 @@ elif defined(nimdoc):
689689

690690
proc close*(socket: AsyncSocket) =
691691
## Closes the socket.
692+
if socket.closed: return
693+
692694
defer:
693695
socket.fd.AsyncFD.closeSocket()
696+
socket.closed = true # TODO: Add extra debugging checks for this.
697+
694698
when defineSsl:
695699
if socket.isSsl:
696700
let res = SSL_shutdown(socket.sslHandle)
@@ -699,7 +703,6 @@ proc close*(socket: AsyncSocket) =
699703
discard
700704
elif res != 1:
701705
raiseSSLError()
702-
socket.closed = true # TODO: Add extra debugging checks for this.
703706

704707
when defineSsl:
705708
proc wrapSocket*(ctx: SslContext, socket: AsyncSocket) =

0 commit comments

Comments
 (0)