25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

Fix component routes unregistration

Fixes #2910
This commit is contained in:
Evgeny Khramtsov 2019-06-17 12:29:04 +03:00
parent c9d3beb9eb
commit 50af436fad

View File

@ -171,7 +171,7 @@ handle_auth_success(_, Mech, _,
ejabberd_router:register_route(H, ejabberd_config:get_myname()), ejabberd_router:register_route(H, ejabberd_config:get_myname()),
ejabberd_hooks:run(component_connected, [H]) ejabberd_hooks:run(component_connected, [H])
end, Routes), end, Routes),
State. State#{routes => Routes}.
handle_auth_failure(_, Mech, Reason, handle_auth_failure(_, Mech, Reason,
#{remote_server := RemoteServer, #{remote_server := RemoteServer,
@ -219,25 +219,12 @@ handle_info(Info, State) ->
?ERROR_MSG("Unexpected info: ~p", [Info]), ?ERROR_MSG("Unexpected info: ~p", [Info]),
State. State.
terminate(Reason, #{stream_state := StreamState, terminate(Reason, #{routes := Routes}) ->
host_opts := HostOpts, lists:foreach(
remote_server := RemoteServer, fun(H) ->
global_routes := GlobalRoutes}) -> ejabberd_router:unregister_route(H),
case StreamState of ejabberd_hooks:run(component_disconnected, [H, Reason])
established -> end, Routes);
Routes = if GlobalRoutes ->
dict:fetch_keys(HostOpts);
true ->
[RemoteServer]
end,
lists:foreach(
fun(H) ->
ejabberd_router:unregister_route(H),
ejabberd_hooks:run(component_disconnected, [H, Reason])
end, Routes);
_ ->
ok
end;
terminate(_Reason, _State) -> terminate(_Reason, _State) ->
ok. ok.