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