From: Evgeny Khramtsov Date: Thu, 18 Jul 2019 18:48:53 +0000 (+0300) Subject: Don't forget to unregister route when the owning process is dead X-Git-Tag: 19.08~49 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ad902c2e16c231bac161b80f9d444afec7781448;p=ejabberd Don't forget to unregister route when the owning process is dead --- diff --git a/src/ejabberd_router.erl b/src/ejabberd_router.erl index fe2db0ce0..a8a471258 100644 --- a/src/ejabberd_router.erl +++ b/src/ejabberd_router.erl @@ -358,6 +358,9 @@ handle_info({'DOWN', MRef, _, Pid, Info}, State) -> ?DEBUG("Process ~p with route registered to ~s " "has terminated unexpectedly with reason: ~p", [P, Domain, Info]), + try unregister_route(Domain, Pid) + catch _:_ -> ok + end, false; (_, _) -> true @@ -462,7 +465,12 @@ monitor_route(Domain, Pid) -> -spec demonitor_route(binary(), pid()) -> ok. demonitor_route(Domain, Pid) -> - ?GEN_SERVER:call(?MODULE, {demonitor, Domain, Pid}, ?CALL_TIMEOUT). + case whereis(?MODULE) == self() of + true -> + ok; + false -> + ?GEN_SERVER:call(?MODULE, {demonitor, Domain, Pid}, ?CALL_TIMEOUT) + end. -spec get_backend() -> module(). get_backend() ->