mirror of
https://gitea.invidious.io/iv-org/lsquic.cr
synced 2024-08-15 00:43:31 +00:00
Catch exception in on_close
This commit is contained in:
parent
aa94a6ea1b
commit
0c0d8748a7
1 changed files with 20 additions and 18 deletions
|
@ -77,19 +77,14 @@ class QUIC::Client
|
|||
end
|
||||
|
||||
ON_READ = ->(s : LibLsquic::StreamT, stream_if_ctx : Void*) do
|
||||
begin
|
||||
stream_ctx = Box(StreamCtx).unbox(stream_if_ctx)
|
||||
|
||||
buffer = Bytes.new(0x600)
|
||||
bytes_read = LibLsquic.stream_read(s, buffer, buffer.size)
|
||||
|
||||
if bytes_read > 0
|
||||
begin
|
||||
stream_ctx.writer.try &.write buffer[0, bytes_read]
|
||||
rescue ex
|
||||
LibLsquic.stream_shutdown(s, 0)
|
||||
LibLsquic.stream_wantread(s, 0)
|
||||
return Box.box(stream_ctx)
|
||||
end
|
||||
elsif bytes_read == 0
|
||||
LibLsquic.stream_shutdown(s, 0)
|
||||
LibLsquic.stream_wantread(s, 0)
|
||||
|
@ -98,15 +93,22 @@ class QUIC::Client
|
|||
else
|
||||
"Could not read response"
|
||||
end
|
||||
|
||||
Box.box(stream_ctx)
|
||||
rescue ex
|
||||
LibLsquic.stream_shutdown(s, 0)
|
||||
LibLsquic.stream_wantread(s, 0)
|
||||
Box.box(stream_ctx)
|
||||
end
|
||||
end
|
||||
|
||||
ON_CLOSE = ->(s : LibLsquic::StreamT, stream_if_ctx : Void*) do
|
||||
begin
|
||||
stream_ctx = Box(StreamCtx).unbox(stream_if_ctx)
|
||||
stream_ctx.writer.try &.close
|
||||
|
||||
Box.box(stream_ctx)
|
||||
rescue ex
|
||||
Box.box(stream_ctx)
|
||||
end
|
||||
end
|
||||
|
||||
EA_PACKETS_OUT = ->(peer_ctx : Void*, specs : LibLsquic::OutSpec*, count : LibC::UInt) do
|
||||
|
|
Loading…
Reference in a new issue