diff --git a/apps/emqx_lua_hook/src/emqx_lua_script.erl b/apps/emqx_lua_hook/src/emqx_lua_script.erl index b54eaf571..f5629309f 100644 --- a/apps/emqx_lua_hook/src/emqx_lua_script.erl +++ b/apps/emqx_lua_hook/src/emqx_lua_script.erl @@ -171,7 +171,7 @@ on_client_subscribe(#{clientid := ClientId, username := Username}, _Properties, case on_client_subscribe_single(ClientId, Username, TopicFilter, LuaState) of false -> {Topic, Opts} = TopicFilter, - [{Topic, Opts#{delete => true}} | Acc]; + [{Topic, Opts#{deny_subscription => true}} | Acc]; NewTopicFilter -> [NewTopicFilter | Acc] end diff --git a/apps/emqx_lua_hook/test/emqx_lua_hook_SUITE.erl b/apps/emqx_lua_hook/test/emqx_lua_hook_SUITE.erl index ea75b138c..9b9f7c410 100644 --- a/apps/emqx_lua_hook/test/emqx_lua_hook_SUITE.erl +++ b/apps/emqx_lua_hook/test/emqx_lua_hook_SUITE.erl @@ -711,7 +711,7 @@ t_stop_sub(_Config) -> OriginalTopicFilters = [{Topic = <<"u">>, Opts = #{nl => 0,qos => 0,rap => 0,rh => 0}}], Props = #{}, - Expected = [{Topic, Opts#{delete => true}}], + Expected = [{Topic, Opts#{deny_subscription => true}}], ?assertEqual(Expected, emqx_hooks:run_fold('client.subscribe', [ClientInfo, Props], OriginalTopicFilters)). diff --git a/apps/emqx_management/src/emqx_management.appup.src b/apps/emqx_management/src/emqx_management.appup.src index 5121efb88..d8ab42853 100644 --- a/apps/emqx_management/src/emqx_management.appup.src +++ b/apps/emqx_management/src/emqx_management.appup.src @@ -1,7 +1,10 @@ %% -*- mode: erlang -*- {VSN, [{<<".*">>, - [{apply,{minirest,stop_http,['http:management']}}, + [%% Stop the http listener to load the latest http handlers. + %% We can only stop these listeners here because we can't get the list of + %% currently started http listener via app-env during the hot upgrade. + {apply,{minirest,stop_http,['http:management']}}, {apply,{minirest,stop_http,['https:management']}}, {restart_application, emqx_management}]}], [{<<".*">>, diff --git a/apps/emqx_management/src/emqx_mgmt_http.erl b/apps/emqx_management/src/emqx_mgmt_http.erl index cf870902e..bd02146ce 100644 --- a/apps/emqx_management/src/emqx_mgmt_http.erl +++ b/apps/emqx_management/src/emqx_mgmt_http.erl @@ -85,6 +85,8 @@ listeners() -> application:get_env(?APP, listeners, []). listener_name(Proto) -> + %% NOTE: this name has referenced by emqx_management.appup.src. + %% Please don't change it except you have got how to handle it in hot-upgrade list_to_atom(atom_to_list(Proto) ++ ":management"). http_handlers() -> diff --git a/include/emqx_release.hrl b/include/emqx_release.hrl index 7961f91ec..e02e076e9 100644 --- a/include/emqx_release.hrl +++ b/include/emqx_release.hrl @@ -29,7 +29,7 @@ -ifndef(EMQX_ENTERPRISE). --define(EMQX_RELEASE, {opensource, "4.4.5-beta.3"}). +-define(EMQX_RELEASE, {opensource, "4.4.5-beta.4"}). -else. diff --git a/lib-ce/emqx_dashboard/src/emqx_dashboard.appup.src b/lib-ce/emqx_dashboard/src/emqx_dashboard.appup.src index 513757418..c44d2f669 100644 --- a/lib-ce/emqx_dashboard/src/emqx_dashboard.appup.src +++ b/lib-ce/emqx_dashboard/src/emqx_dashboard.appup.src @@ -1,11 +1,21 @@ %% -*- mode: erlang -*- {VSN, [ {<<".*">>, - [ {restart_application, emqx_dashboard} + [ %% Stop the http listener to load the latest http handlers. + %% We can only stop these listeners here because we can't get the list of + %% currently started http listener via app-env during the hot upgrade. + {apply, {minirest, stop_http, ['http:dashboard']}} + , {apply, {minirest, stop_http, ['https:dashboard']}} + , {restart_application, emqx_dashboard} ]} ], [ {<<".*">>, - [ {restart_application, emqx_dashboard} + [ %% Stop the http listener to load the latest http handlers. + %% We can only stop these listeners here because we can't get the list of + %% currently started http listener via app-env during the hot upgrade. + {apply, {minirest, stop_http, ['http:dashboard']}} + , {apply, {minirest, stop_http, ['https:dashboard']}} + , {restart_application, emqx_dashboard} ]} ] }. diff --git a/lib-ce/emqx_dashboard/src/emqx_dashboard.erl b/lib-ce/emqx_dashboard/src/emqx_dashboard.erl index 747970637..0cf63194c 100644 --- a/lib-ce/emqx_dashboard/src/emqx_dashboard.erl +++ b/lib-ce/emqx_dashboard/src/emqx_dashboard.erl @@ -80,6 +80,8 @@ listeners() -> application:get_env(?APP, listeners, []). listener_name(Proto) -> + %% NOTE: this name has referenced by emqx_dashboard.appup.src. + %% Please don't change it except you have got how to handle it in hot-upgrade list_to_atom(atom_to_list(Proto) ++ ":dashboard"). %%-------------------------------------------------------------------- diff --git a/src/emqx_channel.erl b/src/emqx_channel.erl index e14597f67..482066d03 100644 --- a/src/emqx_channel.erl +++ b/src/emqx_channel.erl @@ -450,9 +450,9 @@ handle_in(Packet = ?SUBSCRIBE_PACKET(PacketId, Properties, TopicFilters), Channel), TupleTopicFilters2 = lists:foldl( - fun({{Topic, Opts = #{delete := true}}, _QoS}, Acc) -> - Key = {Topic, maps:without([delete], Opts)}, - lists:keydelete(Key, 1, Acc); + fun({{Topic, Opts = #{deny_subscription := true}}, _ReturnCode}, Acc) -> + Key = {Topic, maps:without([deny_subscription], Opts)}, + lists:keyreplace(Key, 1, Acc, {Key, ?RC_UNSPECIFIED_ERROR}); (Tuple = {Key, _Value}, Acc) -> lists:keyreplace(Key, 1, Acc, Tuple) end, diff --git a/test/emqx_broker_SUITE.erl b/test/emqx_broker_SUITE.erl index d009acc6e..3e5ec76e5 100644 --- a/test/emqx_broker_SUITE.erl +++ b/test/emqx_broker_SUITE.erl @@ -625,7 +625,7 @@ t_handle_in_empty_client_subscribe_hook({'end', _Config}) -> ok; t_handle_in_empty_client_subscribe_hook(Config) when is_list(Config) -> Hook = fun(_ClientInfo, _Username, TopicFilter) -> - EmptyFilters = [{T, Opts#{delete => true}} || {T, Opts} <- TopicFilter], + EmptyFilters = [{T, Opts#{deny_subscription => true}} || {T, Opts} <- TopicFilter], {stop, EmptyFilters} end, ok = emqx:hook('client.subscribe', Hook, []), @@ -633,7 +633,7 @@ t_handle_in_empty_client_subscribe_hook(Config) when is_list(Config) -> {ok, C} = emqtt:start_link(), {ok, _} = emqtt:connect(C), {ok, _, RCs} = emqtt:subscribe(C, <<"t">>), - ?assertEqual([], RCs), + ?assertEqual([?RC_UNSPECIFIED_ERROR], RCs), ok after ok = emqx:unhook('client.subscribe', Hook)