summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@lshift.net>2010-04-29 13:06:42 +0100
committerMatthew Sackman <matthew@lshift.net>2010-04-29 13:06:42 +0100
commit28ef5d8d9220f9ffd33fa6094bbe1faa7090cf68 (patch)
tree407f09cca37fc82eb61f3a866dfd79f40be03363
parentfefdf418954b0ff2c4f9bd5c3b018f88a6f30cac (diff)
downloadrabbitmq-server-bug22637.tar.gz
Modify version_compare so that eg 5.0 is eq 5. On application start, check that we have a sufficient version of ertsbug22637
-rw-r--r--include/rabbit.hrl1
-rw-r--r--src/rabbit.erl24
-rw-r--r--src/rabbit_misc.erl16
3 files changed, 29 insertions, 12 deletions
diff --git a/include/rabbit.hrl b/include/rabbit.hrl
index a4abc1ff..145f6104 100644
--- a/include/rabbit.hrl
+++ b/include/rabbit.hrl
@@ -176,6 +176,7 @@
-define(COPYRIGHT_MESSAGE, "Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd.").
-define(INFORMATION_MESSAGE, "Licensed under the MPL. See http://www.rabbitmq.com/").
+-define(ERTS_MINIMUM, "5.6.3").
-define(MAX_WAIT, 16#ffffffff).
diff --git a/src/rabbit.erl b/src/rabbit.erl
index bbda29c9..47684411 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -228,14 +228,18 @@ rotate_logs(BinarySuffix) ->
%%--------------------------------------------------------------------
start(normal, []) ->
- {ok, SupPid} = rabbit_sup:start_link(),
+ case erts_version_check() of
+ ok ->
+ {ok, SupPid} = rabbit_sup:start_link(),
- print_banner(),
- [ok = run_boot_step(Step) || Step <- boot_steps()],
- io:format("~nbroker running~n"),
-
- {ok, SupPid}.
+ print_banner(),
+ [ok = run_boot_step(Step) || Step <- boot_steps()],
+ io:format("~nbroker running~n"),
+ {ok, SupPid};
+ Error ->
+ Error
+ end.
stop(_State) ->
terminated_ok = error_logger:delete_report_handler(rabbit_error_logger),
@@ -248,6 +252,14 @@ stop(_State) ->
%%---------------------------------------------------------------------------
+erts_version_check() ->
+ FoundVer = erlang:system_info(version),
+ case rabbit_misc:version_compare(?ERTS_MINIMUM, FoundVer, lte) of
+ true -> ok;
+ false -> {error, {erlang_version_too_old,
+ {found, FoundVer}, {required, ?ERTS_MINIMUM}}}
+ end.
+
boot_error(Format, Args) ->
io:format("BOOT ERROR: " ++ Format, Args),
error_logger:error_msg(Format, Args),
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl
index 2c180846..59ba2776 100644
--- a/src/rabbit_misc.erl
+++ b/src/rabbit_misc.erl
@@ -598,24 +598,28 @@ version_compare(A, B, gte) ->
version_compare(A, B, Result) ->
Result =:= version_compare(A, B).
-version_compare([], []) ->
+version_compare(A, A) ->
eq;
-version_compare([], _ ) ->
+version_compare([], [$0 | B]) ->
+ version_compare([], dropdot(B));
+version_compare([], _) ->
lt; %% 2.3 < 2.3.1
-version_compare(_ , []) ->
+version_compare([$0 | A], []) ->
+ version_compare(dropdot(A), []);
+version_compare(_, []) ->
gt; %% 2.3.1 > 2.3
version_compare(A, B) ->
{AStr, ATl} = lists:splitwith(fun (X) -> X =/= $. end, A),
{BStr, BTl} = lists:splitwith(fun (X) -> X =/= $. end, B),
ANum = list_to_integer(AStr),
BNum = list_to_integer(BStr),
- if ANum =:= BNum -> ATl1 = lists:dropwhile(fun (X) -> X =:= $. end, ATl),
- BTl1 = lists:dropwhile(fun (X) -> X =:= $. end, BTl),
- version_compare(ATl1, BTl1);
+ if ANum =:= BNum -> version_compare(dropdot(ATl), dropdot(BTl));
ANum < BNum -> lt;
ANum > BNum -> gt
end.
+dropdot(A) -> lists:dropwhile(fun (X) -> X =:= $. end, A).
+
recursive_delete(Files) ->
lists:foldl(fun (Path, ok ) -> recursive_delete1(Path);
(_Path, {error, _Err} = Error) -> Error