]> granicus.if.org Git - ejabberd/commitdiff
Don't forget to unregister route when the owning process is dead
authorEvgeny Khramtsov <ekhramtsov@process-one.net>
Thu, 18 Jul 2019 18:48:53 +0000 (21:48 +0300)
committerEvgeny Khramtsov <ekhramtsov@process-one.net>
Thu, 18 Jul 2019 18:48:53 +0000 (21:48 +0300)
src/ejabberd_router.erl

index fe2db0ce0321e15bb450c3e46083ce5bf956c1be..a8a4712589d987aabf67cadbef541206ead162a9 100644 (file)
@@ -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() ->