summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Watson <tim@rabbitmq.com>2012-05-16 13:48:29 +0100
committerTim Watson <tim@rabbitmq.com>2012-05-16 13:48:29 +0100
commit724a889df13a04ebc2dfe3d5bbac7b1055b3f15f (patch)
tree528f510713c08b52fd0461e30da139b82058c219
parent0ecf08e6ebab4354d6e6c541f1841e636780e51a (diff)
downloadrabbitmq-server-724a889df13a04ebc2dfe3d5bbac7b1055b3f15f.tar.gz
rationalise rabbit_misc:terminate/1/2 with rabbit_misc:quit/1
-rw-r--r--src/rabbit_misc.erl33
-rw-r--r--src/rabbit_plugins.erl4
-rw-r--r--src/rabbit_prelaunch.erl6
3 files changed, 20 insertions, 23 deletions
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl
index cc1417e9..ebef3e65 100644
--- a/src/rabbit_misc.erl
+++ b/src/rabbit_misc.erl
@@ -19,7 +19,7 @@
-include("rabbit_framing.hrl").
-export([method_record_type/1, polite_pause/0, polite_pause/1]).
--export([die/1, frame_error/2, amqp_error/4, terminate/1, terminate/2,
+-export([die/1, frame_error/2, amqp_error/4, quit/1, quit/2,
protocol_error/3, protocol_error/4, protocol_error/1]).
-export([not_found/1, assert_args_equivalence/4]).
-export([dirty_read/1]).
@@ -58,7 +58,6 @@
-export([format_message_queue/2]).
-export([append_rpc_all_nodes/4]).
-export([multi_call/2]).
--export([quit/1]).
-export([os_cmd/1]).
-export([gb_sets_difference/2]).
@@ -87,8 +86,8 @@
-spec(die/1 ::
(rabbit_framing:amqp_exception()) -> channel_or_connection_exit()).
--spec(terminate/1 :: (integer()) -> any()).
--spec(terminate/2 :: (string(), integer()) -> any()).
+-spec(quit/1 :: (integer()) -> any()).
+-spec(quit/2 :: (string(), [term()]) -> any()).
-spec(frame_error/2 :: (rabbit_framing:amqp_method_name(), binary())
-> rabbit_types:connection_exit()).
@@ -207,7 +206,6 @@
-spec(append_rpc_all_nodes/4 :: ([node()], atom(), atom(), [any()]) -> [any()]).
-spec(multi_call/2 ::
([pid()], any()) -> {[{pid(), any()}], [{pid(), any()}]}).
--spec(quit/1 :: (integer() | string()) -> no_return()).
-spec(os_cmd/1 :: (string()) -> string()).
-spec(gb_sets_difference/2 :: (gb_set(), gb_set()) -> gb_set()).
@@ -388,14 +386,20 @@ report_coverage_percentage(File, Cov, NotCov, Mod) ->
confirm_to_sender(Pid, MsgSeqNos) ->
gen_server2:cast(Pid, {confirm, MsgSeqNos, self()}).
-terminate(Fmt, Args) ->
+%%
+%% @doc Halts the emulator after printing out an error message io-formatted with
+%% the supplied arguments. The exit status of the beam process will be set to 1.
+%%
+quit(Fmt, Args) ->
io:format("ERROR: " ++ Fmt ++ "~n", Args),
- terminate(1).
+ quit(1).
-%% like quit/1, uses a slower shutdown on windows
-%% (required to flush stdout), however terminate/1 also blocks
-%% indefinitely until the flush has completed.
-terminate(Status) ->
+%%
+%% @doc Halts the emulator returning the given status code to the os.
+%% On Windows this function will block indefinitely so as to give the io
+%% subsystem time to flush stdout completely.
+%%
+quit(Status) ->
case os:type() of
{unix, _} -> halt(Status);
{win32, _} -> init:stop(Status),
@@ -898,13 +902,6 @@ receive_multi_call([{Mref, Pid} | MonitorPids], Good, Bad) ->
receive_multi_call(MonitorPids, Good, [{Pid, Reason} | Bad])
end.
-%% the slower shutdown on windows required to flush stdout
-quit(Status) ->
- case os:type() of
- {unix, _} -> halt(Status);
- {win32, _} -> init:stop(Status)
- end.
-
os_cmd(Command) ->
Exec = hd(string:tokens(Command, " ")),
case os:find_executable(Exec) of
diff --git a/src/rabbit_plugins.erl b/src/rabbit_plugins.erl
index 06773cdb..aa60cf2c 100644
--- a/src/rabbit_plugins.erl
+++ b/src/rabbit_plugins.erl
@@ -122,12 +122,12 @@ prepare_plugins(EnabledPluginsFile, PluginsDistDir, DestDir) ->
%% Eliminate the contents of the destination directory
case delete_recursively(DestDir) of
ok -> ok;
- {error, E} -> rabbit_misc:terminate("Could not delete dir ~s (~p)",
+ {error, E} -> rabbit_misc:quit("Could not delete dir ~s (~p)",
[DestDir, E])
end,
case filelib:ensure_dir(DestDir ++ "/") of
ok -> ok;
- {error, E2} -> rabbit_misc:terminate("Could not create dir ~s (~p)",
+ {error, E2} -> rabbit_misc:quit("Could not create dir ~s (~p)",
[DestDir, E2])
end,
diff --git a/src/rabbit_prelaunch.erl b/src/rabbit_prelaunch.erl
index d58f54b9..5aa01d18 100644
--- a/src/rabbit_prelaunch.erl
+++ b/src/rabbit_prelaunch.erl
@@ -39,7 +39,7 @@
start() ->
[NodeStr] = init:get_plain_arguments(),
ok = duplicate_node_check(NodeStr),
- rabbit_misc:terminate(0),
+ rabbit_misc:quit(0),
ok.
stop() ->
@@ -61,11 +61,11 @@ duplicate_node_check(NodeStr) ->
"already running on ~p~n",
[NodeName, NodeHost]),
io:format(rabbit_nodes:diagnostics([Node]) ++ "~n"),
- rabbit_misc:terminate(?ERROR_CODE);
+ rabbit_misc:quit(?ERROR_CODE);
false -> ok
end;
{error, EpmdReason} ->
- rabbit_misc:terminate("epmd error for host ~p: ~p (~s)~n",
+ rabbit_misc:quit("epmd error for host ~p: ~p (~s)~n",
[NodeHost, EpmdReason,
case EpmdReason of
address -> "unable to establish tcp connection";