Przeglądaj źródła

feat(quic): fix some listener

William Yang 3 lat temu
rodzic
commit
96a510fbf1

+ 7 - 3
apps/emqx/src/emqx_listeners.erl

@@ -143,9 +143,13 @@ is_running(Type, ListenerId, _Conf) when Type =:= ws; Type =:= wss ->
         _:_ ->
             false
     end;
-is_running(quic, _ListenerId, _Conf) ->
-    %% TODO: quic support
-    false.
+is_running(quic, ListenerId, _Conf) ->
+    case quicer:listener(ListenerId) of
+        {ok, Pid} when is_pid(Pid) ->
+            true;
+        _ ->
+            false
+    end.
 
 current_conns(ID, ListenOn) ->
     {ok, #{type := Type, name := Name}} = parse_listener_id(ID),

+ 1 - 1
apps/emqx/test/emqx_common_test_helpers.erl

@@ -526,7 +526,6 @@ ensure_dashboard_listeners_started(_App) ->
 -spec ensure_quic_listener(Name :: atom(), UdpPort :: inet:port_number()) -> ok.
 ensure_quic_listener(Name, UdpPort) ->
     application:ensure_all_started(quicer),
-    emqx_config:put([listeners, quic, Name, mountpoint], <<>>),
     Conf = #{
         acceptors => 16,
         bind => {{0, 0, 0, 0}, UdpPort},
@@ -545,6 +544,7 @@ ensure_quic_listener(Name, UdpPort) ->
         mountpoint => <<>>,
         zone => default
     },
+    emqx_config:put([listeners, quic, Name], Conf),
     case emqx_listeners:start_listener(quic, Name, Conf) of
         ok -> ok;
         {error, {already_started, _Pid}} -> ok