Просмотр исходного кода

Merge pull request #7098 from HJianBo/autosubs

Gateway should ignore the `{subscribe, TopicTabels}` message produced by auto-subscribe module
JianBo He 4 лет назад
Родитель
Сommit
073743cd57

+ 1 - 1
Makefile

@@ -8,7 +8,7 @@ export EMQX_DEFAULT_BUILDER = ghcr.io/emqx/emqx-builder/5.0-5:1.13.2-24.1.5-4-al
 export EMQX_DEFAULT_RUNNER = alpine:3.14
 export OTP_VSN ?= $(shell $(CURDIR)/scripts/get-otp-vsn.sh)
 export ELIXIR_VSN ?= $(shell $(CURDIR)/scripts/get-elixir-vsn.sh)
-export EMQX_DASHBOARD_VERSION ?= v0.19.0
+export EMQX_DASHBOARD_VERSION ?= v0.20.0
 export DOCKERFILE := deploy/docker/Dockerfile
 export DOCKERFILE_TESTING := deploy/docker/Dockerfile.testing
 ifeq ($(OS),Windows_NT)

+ 6 - 2
apps/emqx_auto_subscribe/src/emqx_auto_subscribe.erl

@@ -60,8 +60,12 @@ test(_) ->
 %% hook
 
 on_client_connected(ClientInfo, ConnInfo, {TopicHandler, Options}) ->
-    TopicTables = erlang:apply(TopicHandler, handle, [ClientInfo, ConnInfo, Options]),
-    self() ! {subscribe, TopicTables};
+    case erlang:apply(TopicHandler, handle, [ClientInfo, ConnInfo, Options]) of
+        [] -> ok;
+        TopicTables ->
+            _ = self() ! {subscribe, TopicTables},
+            ok
+    end;
 on_client_connected(_, _, _) ->
     ok.
 

+ 3 - 0
apps/emqx_gateway/src/exproto/emqx_exproto_channel.erl

@@ -423,6 +423,9 @@ handle_info({hreply, FunName, ok}, Channel)
 handle_info({hreply, FunName, {error, Reason}}, Channel) ->
     {shutdown, {error, {FunName, Reason}}, Channel};
 
+handle_info({subscribe, _}, Channel) ->
+    {ok, Channel};
+
 handle_info(Info, Channel) ->
     ?SLOG(warning, #{ msg => "unexpected_info"
                     , info => Info

+ 3 - 0
apps/emqx_gateway/src/mqttsn/emqx_sn_channel.erl

@@ -1296,6 +1296,9 @@ handle_info(clean_authz_cache, Channel) ->
     ok = emqx_authz_cache:empty_authz_cache(),
     {ok, Channel};
 
+handle_info({subscribe, _}, Channel) ->
+   {ok, Channel};
+
 handle_info(Info, Channel) ->
     ?SLOG(error, #{ msg => "unexpected_info"
                   , info => Info

+ 3 - 0
apps/emqx_gateway/src/stomp/emqx_stomp_channel.erl

@@ -777,6 +777,9 @@ handle_info(clean_authz_cache, Channel) ->
     ok = emqx_authz_cache:empty_authz_cache(),
     {ok, Channel};
 
+handle_info({subscribe, _}, Channel) ->
+    {ok, Channel};
+
 handle_info(Info, Channel) ->
     ?SLOG(error, #{ msg => "unexpected_info"
                   , info => Info

+ 2 - 1
apps/emqx_modules/src/emqx_event_message_api.erl

@@ -15,10 +15,11 @@
 %%--------------------------------------------------------------------
 -module(emqx_event_message_api).
 
+-include("emqx_modules.hrl").
+
 -behaviour(minirest_api).
 
 -import(hoconsc, [mk/2, ref/2]).
--include("emqx_modules.hrl").
 
 -export([ api_spec/0
         , paths/0