Remove the ensure block and close the socket only if there is no exception so that exception during reads do not leave an engine running with no socket.

This commit is contained in:
vhuynh3000 2020-10-22 21:44:58 -07:00
parent 4855742c45
commit 5ef544c1bd
1 changed files with 2 additions and 3 deletions

View File

@ -225,11 +225,10 @@ module QUIC
LibLsquic.engine_packet_in(engine, buffer[0, bytes_read], bytes_read, socket.local_address, socket.remote_address, Box.box(socket), 0) if bytes_read != 0
LibLsquic.engine_process_conns(engine)
end
rescue IO::Error
# may have already been closed
ensure
@socket.try &.close
@socket = nil
rescue IO::Error
# may have already been closed
end
end