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

Fix external components unregistration

This commit is contained in:
Evgeniy Khramtsov 2018-02-14 13:09:27 +03:00
parent 032f796292
commit a65500b6aa

View File

@ -213,17 +213,27 @@ handle_info(Info, State) ->
?ERROR_MSG("Unexpected info: ~p", [Info]), ?ERROR_MSG("Unexpected info: ~p", [Info]),
State. State.
terminate(Reason, #{stream_state := StreamState, host_opts := HostOpts}) -> terminate(Reason, #{stream_state := StreamState,
host_opts := HostOpts,
remote_server := RemoteServer,
global_routes := GlobalRoutes}) ->
case StreamState of case StreamState of
established -> established ->
Routes = if GlobalRoutes ->
dict:fetch_keys(HostOpts);
true ->
[RemoteServer]
end,
lists:foreach( lists:foreach(
fun(H) -> fun(H) ->
ejabberd_router:unregister_route(H), ejabberd_router:unregister_route(H),
ejabberd_hooks:run(component_disconnected, [H, Reason]) ejabberd_hooks:run(component_disconnected, [H, Reason])
end, dict:fetch_keys(HostOpts)); end, Routes);
_ -> _ ->
ok ok
end. end;
terminate(_Reason, _State) ->
ok.
code_change(_OldVsn, State, _Extra) -> code_change(_OldVsn, State, _Extra) ->
{ok, State}. {ok, State}.