Fixes SSL AsyncSocket close problem. Ref #1769. Ref #1759.

This commit is contained in:
Dominik Picheta
2014-12-24 01:52:46 +00:00
parent ea4160b23f
commit 54219245e7

View File

@@ -399,13 +399,13 @@ proc bindAddr*(socket: AsyncSocket, port = Port(0), address = "") {.
proc close*(socket: AsyncSocket) =
## Closes the socket.
socket.fd.TAsyncFD.closeSocket()
defer:
socket.fd.TAsyncFD.closeSocket()
when defined(ssl):
if socket.isSSL:
let res = SslShutdown(socket.sslHandle)
if res == 0:
if SslShutdown(socket.sslHandle) != 1:
raiseSslError()
discard
elif res != 1:
raiseSslError()
socket.closed = true # TODO: Add extra debugging checks for this.