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 957bf15a08)
This commit is contained in:
alaviss
2020-08-12 06:04:54 +00:00
committed by narimiran
parent acfd1b272d
commit dc519a539b

View File

@@ -689,8 +689,12 @@ elif defined(nimdoc):
proc close*(socket: AsyncSocket) =
## Closes the socket.
if socket.closed: return
defer:
socket.fd.AsyncFD.closeSocket()
socket.closed = true # TODO: Add extra debugging checks for this.
when defineSsl:
if socket.isSsl:
let res = SSL_shutdown(socket.sslHandle)
@@ -699,7 +703,6 @@ proc close*(socket: AsyncSocket) =
discard
elif res != 1:
raiseSSLError()
socket.closed = true # TODO: Add extra debugging checks for this.
when defineSsl:
proc wrapSocket*(ctx: SslContext, socket: AsyncSocket) =