fix(quic): setops on stream and handle peer needs stream

- setopts should go for stream
- handle peer_needs_streams for none msquic clients
This commit is contained in:
William Yang 2022-12-22 09:49:20 +01:00
parent ceac5a0ec7
commit 0544a3ca0c
2 changed files with 17 additions and 14 deletions

View File

@ -37,8 +37,7 @@
local_address_changed/3, local_address_changed/3,
peer_address_changed/3, peer_address_changed/3,
streams_available/3, streams_available/3,
% @TODO wait for newer quicer peer_needs_streams/3,
%peer_needs_streams/3,
resumed/3, resumed/3,
new_stream/3 new_stream/3
]). ]).
@ -233,9 +232,12 @@ streams_available(_C, {BidirCnt, UnidirCnt}, S) ->
%% should cope with rate limiting %% should cope with rate limiting
%% @TODO this is not going to get triggered in current version %% @TODO this is not going to get triggered in current version
%% for https://github.com/microsoft/msquic/issues/3120 %% for https://github.com/microsoft/msquic/issues/3120
%% -spec peer_needs_streams(quicer:connection_handle(), undefined, cb_state()) -> cb_ret(). -spec peer_needs_streams(quicer:connection_handle(), undefined, cb_state()) -> cb_ret().
%% peer_needs_streams(_C, undefined, S) -> peer_needs_streams(_C, undefined, S) ->
%% {ok, S}. ?SLOG(info, #{
msg => "ignore: peer need more streames", info => maps:with([conn_pid, ctrl_pid], S)
}),
{ok, S}.
%% @doc handle API calls %% @doc handle API calls
handle_call( handle_call(
@ -255,7 +257,7 @@ 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) -> handle_info({'EXIT', Pid, Reason}, #{ctrl_pid := Pid, conn := Conn} = S) ->
case Reason of case Reason of
normal -> normal ->
quicer:async_shutdown_connection(Conn, ?QUIC_CONNECTION_SHUTDOWN_FLAG_NONE, 0); quicer:async_shutdown_connection(Conn, ?QUIC_CONNECTION_SHUTDOWN_FLAG_NONE, 0);
@ -264,12 +266,13 @@ handle_info({'DOWN', _Ref, process, Pid, Reason}, #{ctrl_pid := Pid, conn := Con
quicer:async_shutdown_connection(Conn, ?QUIC_CONNECTION_SHUTDOWN_FLAG_NONE, 1) quicer:async_shutdown_connection(Conn, ?QUIC_CONNECTION_SHUTDOWN_FLAG_NONE, 1)
end, end,
{ok, S}; {ok, S};
handle_info({'DOWN', _Ref, process, Pid, Reason}, #{streams := Streams} = S) when handle_info({'EXIT', Pid, Reason}, #{streams := Streams} = S) ->
Reason =:= normal orelse
Reason =:= {shutdown, protocol_error}
->
case proplists:is_defined(Pid, Streams) of case proplists:is_defined(Pid, Streams) of
true -> true when
Reason =:= normal orelse
Reason =:= {shutdown, protocol_error} orelse
Reason =:= killed
->
{ok, S}; {ok, S};
false -> false ->
{stop, unknown_pid_down, S} {stop, unknown_pid_down, S}

View File

@ -137,13 +137,13 @@ getstat({quic, Conn, _Stream, _Info}, Stats) ->
Res -> Res Res -> Res
end. end.
setopts(Socket, Opts) -> setopts({quic, _Conn, Stream, _Info}, Opts) ->
lists:foreach( lists:foreach(
fun fun
({Opt, V}) when is_atom(Opt) -> ({Opt, V}) when is_atom(Opt) ->
quicer:setopt(Socket, Opt, V); quicer:setopt(Stream, Opt, V);
(Opt) when is_atom(Opt) -> (Opt) when is_atom(Opt) ->
quicer:setopt(Socket, Opt, true) quicer:setopt(Stream, Opt, true)
end, end,
Opts Opts
), ),