@@ -953,6 +953,72 @@ tc_get_listener_owner(Config) ->
953
953
? assertEqual ({ok , self ()}, quicer :get_listener_owner (L )),
954
954
quicer :close_listener (L ).
955
955
956
+ tc_count_conns (Config ) ->
957
+ Port0 = select_port (),
958
+ Port1 = select_port (),
959
+ ServerConnCallback = example_server_connection ,
960
+ ServerStreamCallback = example_server_stream ,
961
+ ListenerOpts = [
962
+ {conn_acceptors , 32 },
963
+ {peer_bidi_stream_count , 0 },
964
+ {peer_unidi_stream_count , 2 }
965
+ | default_listen_opts (Config )
966
+ ],
967
+ ConnectionOpts = [
968
+ {conn_callback , ServerConnCallback },
969
+ {stream_acceptors , 2 }
970
+ | default_conn_opts ()
971
+ ],
972
+ StreamOpts = [
973
+ {stream_callback , ServerStreamCallback }
974
+ | default_stream_opts ()
975
+ ],
976
+ Options = {ListenerOpts , ConnectionOpts , StreamOpts },
977
+
978
+ % % GIVEN: Two QUIC listeners
979
+ {ok , QuicApp } = quicer :spawn_listener (sample , Port0 , Options ),
980
+
981
+ {ok , QuicApp2 } = quicer :spawn_listener (sample2 , Port1 , Options ),
982
+
983
+ ClientConnOpts = default_conn_opts_verify (Config , ca ),
984
+
985
+ % % WHEN: a client is connected to the first listener
986
+ {ok , ClientConnPid } = example_client_connection :start_link (
987
+ " localhost" ,
988
+ Port0 ,
989
+ {ClientConnOpts , default_stream_opts ()}
990
+ ),
991
+ #{is_resumed := false } = snabbkaffe :retry (
992
+ 50 ,
993
+ 20 ,
994
+ fun () ->
995
+ #{is_resumed := false } = quicer_connection :get_cb_state (ClientConnPid )
996
+ end
997
+ ),
998
+
999
+ % % Then the first listener has one connection and other has none
1000
+ ? assertEqual ({1 , 0 }, {
1001
+ quicer_listener :count_conns (QuicApp ), quicer_listener :count_conns (QuicApp2 )
1002
+ }),
1003
+
1004
+ % % WHEN: client is stopped
1005
+ gen_server :stop (ClientConnPid ),
1006
+
1007
+ % % THEN: both listeners have no connections
1008
+ {0 , 0 } = snabbkaffe :retry (
1009
+ 10 ,
1010
+ 100 ,
1011
+ fun () ->
1012
+ {0 , 0 } =
1013
+ {quicer_listener :count_conns (QuicApp ), quicer_listener :count_conns (QuicApp2 )}
1014
+ end
1015
+ ),
1016
+
1017
+ quicer :terminate_listener (sample ),
1018
+ quicer :terminate_listener (sample2 ).
1019
+
1020
+ % %% Helpers
1021
+
956
1022
select_port () ->
957
1023
Port = select_free_port (quic ),
958
1024
timer :sleep (100 ),
0 commit comments