diff options
| author | Matthias Radestock <matthias@lshift.net> | 2009-08-07 00:55:46 +0100 |
|---|---|---|
| committer | Matthias Radestock <matthias@lshift.net> | 2009-08-07 00:55:46 +0100 |
| commit | 71dafaaa69a9e4618f368d0a3605a5840d25fbca (patch) | |
| tree | 7395f30699ce77f8ebeda2e4ef83e5dbfb9e8f18 /src | |
| parent | 8b99b9b278d7bee1d2b5eb13da831e16656c26c6 (diff) | |
| download | rabbitmq-server-git-71dafaaa69a9e4618f368d0a3605a5840d25fbca.tar.gz | |
factor out common termination handling
Diffstat (limited to 'src')
| -rw-r--r-- | src/gen_server2.erl | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/src/gen_server2.erl b/src/gen_server2.erl index 5578342bfb..36fb4fa8c3 100644 --- a/src/gen_server2.erl +++ b/src/gen_server2.erl @@ -528,13 +528,9 @@ pre_hibernate(Parent, Name, State, Mod, TimeoutState, Queue, Debug) -> {hibernate, NState} -> hibernate(Parent, Name, NState, Mod, TimeoutState, Queue, Debug); - {stop, Reason, NState} -> - terminate(Reason, Name, pre_hibernate, Mod, NState, Debug); - {'EXIT', What} -> - terminate(What, Name, pre_hibernate, Mod, State, Debug); Reply -> - terminate({bad_return_value, Reply}, Name, pre_hibernate, - Mod, State, Debug) + handle_common_termination(Reply, Name, pre_hibernate, + Mod, State, Debug) end; false -> hibernate(Parent, Name, State, Mod, TimeoutState, Queue, Debug) @@ -550,13 +546,9 @@ post_hibernate(Parent, Name, State, Mod, TimeoutState, Queue, Debug) -> {noreply, NState, Time} -> process_next_msg(Parent, Name, NState, Mod, Time, TimeoutState, Queue, Debug); - {stop, Reason, NState} -> - terminate(Reason, Name, post_hibernate, Mod, NState, Debug); - {'EXIT', What} -> - terminate(What, Name, post_hibernate, Mod, State, Debug); Reply -> - terminate({bad_return_value, Reply}, Name, post_hibernate, - Mod, State, Debug) + handle_common_termination(Reply, Name, post_hibernate, + Mod, State, Debug) end; false -> %% use hibernate here, not infinity. This matches @@ -877,12 +869,8 @@ handle_common_reply(Reply, Parent, Name, Msg, Mod, State, loop(Parent, Name, NState, Mod, infinity, TimeoutState, Queue, []); {noreply, NState, Time1} -> loop(Parent, Name, NState, Mod, Time1, TimeoutState, Queue, []); - {stop, Reason, NState} -> - terminate(Reason, Name, Msg, Mod, NState, []); - {'EXIT', What} -> - terminate(What, Name, Msg, Mod, State, []); - _ -> - terminate({bad_return_value, Reply}, Name, Msg, Mod, State, []) + _ -> + handle_common_termination(Reply, Name, Msg, Mod, State, []) end. handle_common_reply(Reply, Parent, Name, Msg, Mod, State, TimeoutState, Queue, @@ -897,6 +885,12 @@ handle_common_reply(Reply, Parent, Name, Msg, Mod, State, TimeoutState, Queue, Debug1 = sys:handle_debug(Debug, {?MODULE, print_event}, Name, {noreply, NState}), loop(Parent, Name, NState, Mod, Time1, TimeoutState, Queue, Debug1); + _ -> + handle_common_termination(Reply, Name, Msg, Mod, State, Debug) + end. + +handle_common_termination(Reply, Name, Msg, Mod, State, Debug) -> + case Reply of {stop, Reason, NState} -> terminate(Reason, Name, Msg, Mod, NState, Debug); {'EXIT', What} -> |
