]> granicus.if.org Git - ejabberd/commitdiff
Catch potential exceptions in gen_mod:wait_for_process
authorPaweł Chmielowski <pchmielowski@process-one.net>
Wed, 24 Apr 2019 11:46:09 +0000 (13:46 +0200)
committerPaweł Chmielowski <pchmielowski@process-one.net>
Wed, 24 Apr 2019 11:46:16 +0000 (13:46 +0200)
Seems that at ejabberd shutdown, process may terminate before that function
is called, and in that case erlang:monitor throws exception.

src/gen_mod.erl

index cec3ddb245cc4f53a683b32ac1264d1b745ddbc3..4dc972fd9d5112f39c3125f562fdc7f386c2c1cf 100644 (file)
@@ -364,8 +364,13 @@ stop_module_keep_config(Host, Module) ->
     end.
 
 wait_for_process(Process) ->
-    MonitorReference = erlang:monitor(process, Process),
-    wait_for_stop(Process, MonitorReference).
+    try erlang:monitor(process, Process) of
+       MonitorReference ->
+           wait_for_stop(Process, MonitorReference)
+    catch
+       _:_ ->
+           ok
+    end.
 
 wait_for_stop(Process, MonitorReference) ->
     receive