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.
|
%% @doc handle DOWN messages from streams.
|
||||||
%% @TODO handle DOWN from supervisor?
|
%% @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
|
handle_info({'DOWN', _Ref, process, Pid, Reason}, #{streams := Streams} = S) when
|
||||||
Reason =:= normal orelse
|
Reason =:= normal orelse
|
||||||
Reason =:= {shutdown, protocol_error}
|
Reason =:= {shutdown, protocol_error}
|
||||||
|
|
|
@ -164,9 +164,13 @@ fast_close({ConnOwner, Conn, _ConnInfo}) when is_pid(ConnOwner) ->
|
||||||
%% handshake aborted.
|
%% handshake aborted.
|
||||||
quicer:async_shutdown_connection(Conn, ?QUIC_CONNECTION_SHUTDOWN_FLAG_NONE, 0),
|
quicer:async_shutdown_connection(Conn, ?QUIC_CONNECTION_SHUTDOWN_FLAG_NONE, 0),
|
||||||
ok;
|
ok;
|
||||||
fast_close({quic, Conn, _Stream, _Info}) ->
|
fast_close({quic, _Conn, Stream, _Info}) ->
|
||||||
%% Since we shutdown the control stream, we shutdown the connection as well
|
%% Force flush
|
||||||
quicer:async_shutdown_connection(Conn, ?QUIC_CONNECTION_SHUTDOWN_FLAG_NONE, 0),
|
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.
|
ok.
|
||||||
|
|
||||||
-spec ensure_ok_or_exit(atom(), list(term())) -> term().
|
-spec ensure_ok_or_exit(atom(), list(term())) -> term().
|
||||||
|
|
Loading…
Reference in New Issue