diff options
| author | Simon MacMullen <simon@rabbitmq.com> | 2011-07-01 12:35:55 +0100 |
|---|---|---|
| committer | Simon MacMullen <simon@rabbitmq.com> | 2011-07-01 12:35:55 +0100 |
| commit | e8387f915f2305400d6c0c92325da609b83c5450 (patch) | |
| tree | c5cf62d04a53815eb6686b86542599bc926233c9 /src | |
| parent | 51d27e2e6dcf4dabcf45b3ac9892f48c3d029a56 (diff) | |
| download | rabbitmq-server-git-e8387f915f2305400d6c0c92325da609b83c5450.tar.gz | |
More cosmetic.
Diffstat (limited to 'src')
| -rw-r--r-- | src/mirrored_supervisor.erl | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/mirrored_supervisor.erl b/src/mirrored_supervisor.erl index d9ae3407b4..1622528d14 100644 --- a/src/mirrored_supervisor.erl +++ b/src/mirrored_supervisor.erl @@ -114,8 +114,7 @@ init({SupName, _Args}) -> handle_call({start_child, ChildSpec}, _From, State = #state{name = SupName}) -> {reply, case mnesia:transaction(fun() -> check_start(ChildSpec) end) of {atomic, start} -> io:format("Start ~p~n", [id(ChildSpec)]), - apply(?SUPERVISOR, - start_child, [SupName, ChildSpec]); + start(SupName, ChildSpec); {atomic, already} -> io:format("Already ~p~n", [id(ChildSpec)]), {ok, already} end, State}; @@ -123,7 +122,7 @@ handle_call({start_child, ChildSpec}, _From, State = #state{name = SupName}) -> handle_call({delete_child, ChildSpec}, _From, State = #state{name = SupName}) -> {atomic, ok} = mnesia:transaction(fun() -> delete(ChildSpec) end), - {reply, apply(?SUPERVISOR, delete_child, [SupName, id(ChildSpec)]), State}; + {reply, stop(SupName, id(ChildSpec)), State}; handle_call({msg, F, A}, _From, State) -> {reply, apply(?SUPERVISOR, F, A), State}; @@ -151,8 +150,7 @@ handle_info({'DOWN', _Ref, process, Pid, _Reason}, [Self | _] -> {atomic, ChildSpecs} = mnesia:transaction(fun() -> restart_all(Pid) end), [begin - apply(?SUPERVISOR, start_child, - [SupName, ChildSpec]), + start(SupName, ChildSpec), io:format("Restarted ~p~n", [id(ChildSpec)]) end || ChildSpec <- ChildSpecs]; _ -> ok @@ -196,6 +194,12 @@ write(ChildSpec) -> delete(ChildSpec) -> ok = mnesia:delete({?MNESIA_TABLE, id(ChildSpec)}). +start(SupName, ChildSpec) -> + apply(?SUPERVISOR, start_child, [SupName, ChildSpec]). + +stop(SupName, ChildSpec) -> + apply(?SUPERVISOR, delete_child, [SupName, id(ChildSpec)]). + id({Id, _, _, _, _, _}) -> Id. update(ChildSpec) -> |
