feat(quic): workaround to flushing the send buffer after conn shutdown
Could not find a way to ensure msquic flush the send buffer after calling ConnectionShutdown. So just close the ctrl stream and let conn owner shutdown the conn.
This commit is contained in:
parent
04a8a49dbe
commit
5bdcb0562d
|
@ -255,6 +255,15 @@ handle_call(_Req, _From, S) ->
|
|||
|
||||
%% @doc handle DOWN messages from streams.
|
||||
%% @TODO handle DOWN from supervisor?
|
||||
handle_info({'DOWN', _Ref, process, Pid, Reason}, #{ctrl_pid := Pid, conn := Conn} = S) ->
|
||||
case Reason of
|
||||
normal ->
|
||||
quicer:async_shutdown_connection(Conn, ?QUIC_CONNECTION_SHUTDOWN_FLAG_NONE, 0);
|
||||
_ ->
|
||||
%% @TODO have some reasons mappings here.
|
||||
quicer:async_shutdown_connection(Conn, ?QUIC_CONNECTION_SHUTDOWN_FLAG_NONE, 1)
|
||||
end,
|
||||
{ok, S};
|
||||
handle_info({'DOWN', _Ref, process, Pid, Reason}, #{streams := Streams} = S) when
|
||||
Reason =:= normal orelse
|
||||
Reason =:= {shutdown, protocol_error}
|
||||
|
|
|
@ -164,9 +164,13 @@ fast_close({ConnOwner, Conn, _ConnInfo}) when is_pid(ConnOwner) ->
|
|||
%% handshake aborted.
|
||||
quicer:async_shutdown_connection(Conn, ?QUIC_CONNECTION_SHUTDOWN_FLAG_NONE, 0),
|
||||
ok;
|
||||
fast_close({quic, Conn, _Stream, _Info}) ->
|
||||
%% Since we shutdown the control stream, we shutdown the connection as well
|
||||
quicer:async_shutdown_connection(Conn, ?QUIC_CONNECTION_SHUTDOWN_FLAG_NONE, 0),
|
||||
fast_close({quic, _Conn, Stream, _Info}) ->
|
||||
%% Force flush
|
||||
quicer:async_shutdown_stream(Stream),
|
||||
%% @FIXME Since we shutdown the control stream, we shutdown the connection as well
|
||||
%% *BUT* Msquic does not flush the send buffer if we shutdown the connection after
|
||||
%% gracefully shutdown the stream.
|
||||
% quicer:async_shutdown_connection(Conn, ?QUIC_CONNECTION_SHUTDOWN_FLAG_NONE, 0),
|
||||
ok.
|
||||
|
||||
-spec ensure_ok_or_exit(atom(), list(term())) -> term().
|
||||
|
|
Loading…
Reference in New Issue