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.
This commit is contained in:
alaviss 2020-08-12 06:04:54 +00:00 • committed by GitHub
commit 957bf15a08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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