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 | e608954f1ff8604f944edbf254a1f7ae7d9d5c4f (patch) | |
tree | 7395f30699ce77f8ebeda2e4ef83e5dbfb9e8f18 | |
parent | 0a990e04cb58c0c0cfe539c1911dcc7f22beb3d5 (diff) | |
download | rabbitmq-server-bug21087.tar.gz |
factor out common termination handlingbug21087
-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 5578342b..36fb4fa8 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} -> |