From d0ac7f6852722f7247238bf2c19abff653cbe9ad Mon Sep 17 00:00:00 2001 From: Simon MacMullen Date: Tue, 11 Feb 2014 14:07:56 +0000 Subject: Handle down messages from the delegate, since that's what we're monitoring locally. And make sure that cast/2 has cast-like semantics - don't blow up if the gen_server has stopped. --- src/mirrored_supervisor.erl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mirrored_supervisor.erl b/src/mirrored_supervisor.erl index f44b1f1d..ae35526f 100644 --- a/src/mirrored_supervisor.erl +++ b/src/mirrored_supervisor.erl @@ -245,7 +245,9 @@ count_children(Sup) -> fold(count_children, Sup, fun add_proplists/2). check_childspecs(Specs) -> ?SUPERVISOR:check_childspecs(Specs). call(Sup, Msg) -> ?GEN_SERVER:call(mirroring(Sup), Msg, infinity). -cast(Sup, Msg) -> ?GEN_SERVER:cast(mirroring(Sup), Msg). +cast(Sup, Msg) -> with_exit_handler( + fun() -> ok end, + fun() -> ?GEN_SERVER:cast(mirroring(Sup), Msg) end). find_call(Sup, Id, Msg) -> Group = call(Sup, group), @@ -369,7 +371,7 @@ handle_cast(Msg, State) -> {stop, {unexpected_cast, Msg}, State}. handle_info({'DOWN', _Ref, process, Pid, Reason}, - State = #state{overall = Pid, group = Group}) -> + State = #state{delegate = Pid, group = Group}) -> %% Since the delegate is temporary, its death won't cause us to %% die. Since the overall supervisor kills processes in reverse %% order when shutting down "from above" and we started after the -- cgit v1.2.1