ensure file descriptor is closed

This commit is contained in:
Will Szumski 2014-12-18 00:45:02 +00:00
commit 1b614ffc80

View file

@ -432,6 +432,7 @@ proc accept*(server: Socket, client: var Socket,
proc close*(socket: Socket) = proc close*(socket: Socket) =
## Closes a socket. ## Closes a socket.
try:
when defined(ssl): when defined(ssl):
if socket.isSSL: if socket.isSSL:
ErrClearError() ErrClearError()
@ -444,6 +445,7 @@ proc close*(socket: Socket) =
discard discard
elif res != 1: elif res != 1:
socketError(socket, res) socketError(socket, res)
finally:
socket.fd.close() socket.fd.close()
proc toCInt*(opt: SOBool): cint = proc toCInt*(opt: SOBool): cint =