Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply default stream start flag #283

Merged
merged 3 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/quicer.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,7 @@ stats_map(_) ->
undefined.

default_stream_opts() ->
#{active => true}.
#{active => true, start_flag => ?QUIC_STREAM_START_FLAG_SHUTDOWN_ON_FAIL}.

default_conn_opts() ->
#{
Expand Down
6 changes: 3 additions & 3 deletions test/prop_stateful_client_conn.erl
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,11 @@ postcondition(
) ->
Owner =/= self();
postcondition(
#{owner := Owner, state := connected},
{call, quicer, controlling_process, [_, _]},
#{owner := _, state := connected},
{call, quicer, controlling_process, [_, NewOwner]},
{error, owner_dead}
) ->
Owner =/= self();
NewOwner =/= self();
%% postcondition(#{owner := Owner, state := closed} = State, {call, quicer, controlling_process, [_, _]}, {error, not_owner}) ->
%% true;
postcondition(#{handle := H, state := connected}, {call, quicer, get_connections, _}, Conns) ->
Expand Down
42 changes: 22 additions & 20 deletions test/prop_stateful_server_conn.erl
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,27 @@
prop_server_state_test(opts) ->
[{numtests, 2000}].
prop_server_state_test() ->
%% dbg:tracer(process, {fun dbg:dhandler/2,group_leader()}),
%% dbg:p(self(), c),
%% dbg:tp(quicer, cx),
process_flag(trap_exit, true),
{ok, L} = quicer:listen(?PORT, default_listen_opts()),
put(listener, L),
?FORALL(
Cmds,
commands(?MODULE),
begin
{History, State, Result} = run_commands(?MODULE, Cmds),
?WHENFAIL(
io:format(
"History: ~p\nState: ~p\nResult: ~p\n",
[History, State, Result]
),
aggregate(command_names(Cmds), Result =:= ok)
)
end
?SETUP(
fun() ->
{ok, L} = quicer:listen(?PORT, default_listen_opts()),
put(listener, L),
fun() -> quicer:close_listener(L) end
end,
?FORALL(
Cmds,
commands(?MODULE),
begin
{History, State, Result} = run_commands(?MODULE, Cmds),
?WHENFAIL(
io:format(
"History: ~p\nState: ~p\nResult: ~p\n",
[History, State, Result]
),
aggregate(command_names(Cmds), Result =:= ok)
)
end
)
).

%%%%%%%%%%%%%
Expand All @@ -63,7 +65,7 @@ prop_server_state_test() ->
%% @doc Initial model value at system start. Should be deterministic.
initial_state() ->
process_flag(trap_exit, true),
{ok, L} = quicer:async_accept(get(listener), #{active => false}),
{ok, _L} = quicer:async_accept(get(listener), #{active => false}),

%%% We don't care about the client thus no linking.
spawn(fun() ->
Expand Down Expand Up @@ -265,7 +267,7 @@ postcondition(
is_pid(NewOwner);
%% postcondition(#{owner := Owner, state := closed} = State, {call, quicer, controlling_process, [_, _]}, {error, not_owner}) ->
%% true;
postcondition(#{handle := H, state := S}, {call, quicer, get_connections, _}, Conns) when
postcondition(#{handle := _H, state := _S}, {call, quicer, get_connections, _}, Conns) when
is_list(Conns)
->
%% @TODO check why handle is not member
Expand Down
4 changes: 2 additions & 2 deletions test/prop_stateful_stream.erl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ prop_stateful_client_stream_test() ->
commands(?MODULE),
begin
flush_quic_msgs(),
{ok, H} = quicer:connect("localhost", 14569, default_conn_opts(), 10000),
{ok, H} = quicer:connect("localhost", 14571, default_conn_opts(), 10000),
{History, State, Result} = run_commands(?MODULE, Cmds, [{conn_handle, H}]),
quicer:async_shutdown_connection(H, ?QUIC_CONNECTION_SHUTDOWN_FLAG_SILENT, 0),
?WHENFAIL(
Expand Down Expand Up @@ -272,7 +272,7 @@ flush_quic_msgs() ->
%%%%%%%%%%%%%%%%%%%%%%%
listener_start_link(ListenerName) ->
application:ensure_all_started(quicer),
LPort = 14569,
LPort = 14571,
ListenerOpts = default_listen_opts(),
ConnectionOpts = [
{conn_callback, example_server_connection},
Expand Down
2 changes: 1 addition & 1 deletion test/quicer_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1927,7 +1927,7 @@ tc_stream_open_flag_unidirectional(Config) ->
receive
{quic, <<"ping1">>, Stm, _} ->
ct:fail("unidirectional stream should not receive any");
{quic, stream_closed, Stm, #{is_conn_shutdown := true, is_app_closing := false}} ->
{quic, stream_closed, Stm, #{is_conn_shutdown := _, is_app_closing := false}} ->
ct:pal("stream is closed due to connecion idle")
end,
?assert(is_integer(Rid)),
Expand Down
Loading