summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--include/rabbit_backing_queue_spec.hrl5
-rw-r--r--packaging/macports/Portfile.in22
-rw-r--r--src/rabbit_access_control.erl10
-rw-r--r--src/rabbit_amqqueue.erl11
-rw-r--r--src/rabbit_amqqueue_process.erl6
-rw-r--r--src/rabbit_backing_queue.erl20
-rw-r--r--src/rabbit_dialyzer.erl4
-rw-r--r--src/rabbit_exchange.erl1
-rw-r--r--src/rabbit_exchange_type_topic.erl3
-rw-r--r--src/rabbit_invariable_queue.erl13
-rw-r--r--src/rabbit_misc.erl2
-rw-r--r--src/rabbit_multi.erl6
-rw-r--r--src/rabbit_sup.erl8
-rw-r--r--src/rabbit_tests.erl2
15 files changed, 63 insertions, 54 deletions
diff --git a/Makefile b/Makefile
index a66d0640e3..5694292dcf 100644
--- a/Makefile
+++ b/Makefile
@@ -41,10 +41,10 @@ RABBIT_PLT=rabbit.plt
ifndef USE_SPECS
# our type specs rely on features and bug fixes in dialyzer that are
-# only available in R13B04 upwards (R13B04 is erts 5.7.5)
+# only available in R14A upwards (R13B04 is erts 5.7.5)
#
# NB: the test assumes that version number will only contain single digits
-USE_SPECS=$(shell if [ $$(erl -noshell -eval 'io:format(erlang:system_info(version)), halt().') \> "5.7.4" ]; then echo "true"; else echo "false"; fi)
+USE_SPECS=$(shell if [ $$(erl -noshell -eval 'io:format(erlang:system_info(version)), halt().') \> "5.7.5" ]; then echo "true"; else echo "false"; fi)
endif
#other args: +native +"{hipe,[o3,verbose]}" -Ddebug=true +debug_info +no_strict_record_tests
diff --git a/include/rabbit_backing_queue_spec.hrl b/include/rabbit_backing_queue_spec.hrl
index 05dc1464cd..005994f09f 100644
--- a/include/rabbit_backing_queue_spec.hrl
+++ b/include/rabbit_backing_queue_spec.hrl
@@ -38,6 +38,7 @@
-type(ack_required() :: boolean()).
-spec(start/1 :: ([rabbit_amqqueue:name()]) -> 'ok').
+-spec(stop/0 :: () -> 'ok').
-spec(init/3 :: (rabbit_amqqueue:name(), is_durable(), attempt_recovery()) -> state()).
-spec(terminate/1 :: (state()) -> state()).
-spec(delete_and_terminate/1 :: (state()) -> state()).
@@ -57,7 +58,7 @@
-spec(set_ram_duration_target/2 ::
(('undefined' | 'infinity' | number()), state()) -> state()).
-spec(ram_duration/1 :: (state()) -> {number(), state()}).
--spec(needs_sync/1 :: (state()) -> boolean()).
--spec(sync/1 :: (state()) -> state()).
+-spec(needs_idle_timeout/1 :: (state()) -> boolean()).
+-spec(idle_timeout/1 :: (state()) -> state()).
-spec(handle_pre_hibernate/1 :: (state()) -> state()).
-spec(status/1 :: (state()) -> [{atom(), any()}]).
diff --git a/packaging/macports/Portfile.in b/packaging/macports/Portfile.in
index be0d24d75f..082d712fbc 100644
--- a/packaging/macports/Portfile.in
+++ b/packaging/macports/Portfile.in
@@ -75,22 +75,12 @@ post-destroot {
reinplace -E "s:(/etc/rabbitmq/rabbitmq.conf):${prefix}\\1:g" \
${realsbin}/rabbitmq-env
- reinplace -E "s:(CLUSTER_CONFIG_FILE)=/:\\1=${prefix}/:" \
- ${realsbin}/rabbitmq-multi \
- ${realsbin}/rabbitmq-server \
- ${realsbin}/rabbitmqctl
- reinplace -E "s:(LOG_BASE)=/:\\1=${prefix}/:" \
- ${realsbin}/rabbitmq-multi \
- ${realsbin}/rabbitmq-server \
- ${realsbin}/rabbitmqctl
- reinplace -E "s:(MNESIA_BASE)=/:\\1=${prefix}/:" \
- ${realsbin}/rabbitmq-multi \
- ${realsbin}/rabbitmq-server \
- ${realsbin}/rabbitmqctl
- reinplace -E "s:(PIDS_FILE)=/:\\1=${prefix}/:" \
- ${realsbin}/rabbitmq-multi \
- ${realsbin}/rabbitmq-server \
- ${realsbin}/rabbitmqctl
+ foreach var {CONFIG_FILE CLUSTER_CONFIG_FILE LOG_BASE MNESIA_BASE PIDS_FILE} {
+ reinplace -E "s:^($var)=/:\\1=${prefix}/:" \
+ ${realsbin}/rabbitmq-multi \
+ ${realsbin}/rabbitmq-server \
+ ${realsbin}/rabbitmqctl
+ }
xinstall -m 555 ${filespath}/rabbitmq-script-wrapper \
${wrappersbin}/rabbitmq-multi
diff --git a/src/rabbit_access_control.erl b/src/rabbit_access_control.erl
index 30bae25e5a..3aaf59281e 100644
--- a/src/rabbit_access_control.erl
+++ b/src/rabbit_access_control.erl
@@ -177,11 +177,9 @@ check_resource_access(Username,
<<"">> -> <<$^, $$>>;
RE -> RE
end,
- case regexp:match(
- binary_to_list(Name),
- binary_to_list(PermRegexp)) of
- {match, _, _} -> true;
- nomatch -> false
+ case re:run(Name, PermRegexp, [{capture, none}]) of
+ match -> true;
+ nomatch -> false
end
end,
if Res -> ok;
@@ -306,7 +304,7 @@ list_vhosts() ->
validate_regexp(RegexpBin) ->
Regexp = binary_to_list(RegexpBin),
- case regexp:parse(Regexp) of
+ case re:compile(Regexp) of
{ok, _} -> ok;
{error, Reason} -> throw({error, {invalid_regexp, Regexp, Reason}})
end.
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl
index 2c5465e690..0489f13961 100644
--- a/src/rabbit_amqqueue.erl
+++ b/src/rabbit_amqqueue.erl
@@ -31,7 +31,7 @@
-module(rabbit_amqqueue).
--export([start/0, declare/5, delete/3, purge/1]).
+-export([start/0, stop/0, declare/5, delete/3, purge/1]).
-export([internal_declare/2, internal_delete/1,
maybe_run_queue_via_backing_queue/2,
update_ram_duration/1, set_ram_duration_target/2,
@@ -72,6 +72,7 @@
'ok' | {'error', [{'error' | 'exit' | 'throw', any()}]}).
-spec(start/0 :: () -> 'ok').
+-spec(stop/0 :: () -> 'ok').
-spec(declare/5 ::
(name(), boolean(), boolean(),
rabbit_framing:amqp_table(), rabbit_types:maybe(pid()))
@@ -156,7 +157,7 @@
start() ->
DurableQueues = find_durable_queues(),
- {ok, BQ} = application:get_env(backing_queue_module),
+ {ok, BQ} = application:get_env(rabbit, backing_queue_module),
ok = BQ:start([QName || #amqqueue{name = QName} <- DurableQueues]),
{ok,_} = supervisor:start_child(
rabbit_sup,
@@ -166,6 +167,12 @@ start() ->
_RealDurableQueues = recover_durable_queues(DurableQueues),
ok.
+stop() ->
+ ok = supervisor:terminate_child(rabbit_sup, rabbit_amqqueue_sup),
+ ok = supervisor:delete_child(rabbit_sup, rabbit_amqqueue_sup),
+ {ok, BQ} = application:get_env(rabbit, backing_queue_module),
+ ok = BQ:stop().
+
find_durable_queues() ->
Node = node(),
%% TODO: use dirty ops instead
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl
index e7d4817dee..c099c0510d 100644
--- a/src/rabbit_amqqueue_process.erl
+++ b/src/rabbit_amqqueue_process.erl
@@ -192,7 +192,7 @@ next_state(State) ->
State1 = #q{backing_queue = BQ, backing_queue_state = BQS} =
ensure_rate_timer(State),
State2 = ensure_stats_timer(State1),
- case BQ:needs_sync(BQS)of
+ case BQ:needs_idle_timeout(BQS)of
true -> {ensure_sync_timer(State2), 0};
false -> {stop_sync_timer(State2), hibernate}
end.
@@ -201,7 +201,7 @@ ensure_sync_timer(State = #q{sync_timer_ref = undefined, backing_queue = BQ}) ->
{ok, TRef} = timer:apply_after(
?SYNC_INTERVAL,
rabbit_amqqueue, maybe_run_queue_via_backing_queue,
- [self(), fun (BQS) -> BQ:sync(BQS) end]),
+ [self(), fun (BQS) -> BQ:idle_timeout(BQS) end]),
State#q{sync_timer_ref = TRef};
ensure_sync_timer(State) ->
State.
@@ -860,7 +860,7 @@ handle_info({'DOWN', _MonitorRef, process, DownPid, _Reason}, State) ->
handle_info(timeout, State = #q{backing_queue = BQ}) ->
noreply(maybe_run_queue_via_backing_queue(
- fun (BQS) -> BQ:sync(BQS) end, State));
+ fun (BQS) -> BQ:idle_timeout(BQS) end, State));
handle_info({'EXIT', _Pid, Reason}, State) ->
{stop, Reason, State};
diff --git a/src/rabbit_backing_queue.erl b/src/rabbit_backing_queue.erl
index 432d62900b..2230c507e9 100644
--- a/src/rabbit_backing_queue.erl
+++ b/src/rabbit_backing_queue.erl
@@ -42,6 +42,11 @@ behaviour_info(callbacks) ->
%% shared resources.
{start, 1},
+ %% Called to tear down any state/resources. NB: Implementations
+ %% should not depend on this function being called on shutdown
+ %% and instead should hook into the rabbit supervision hierarchy.
+ {stop, 0},
+
%% Initialise the backing queue and its state.
{init, 3},
@@ -113,14 +118,15 @@ behaviour_info(callbacks) ->
%% queue.
{ram_duration, 1},
- %% Should 'sync' be called as soon as the queue process can
- %% manage (either on an empty mailbox, or when a timer fires)?
- {needs_sync, 1},
+ %% Should 'idle_timeout' be called as soon as the queue process
+ %% can manage (either on an empty mailbox, or when a timer
+ %% fires)?
+ {needs_idle_timeout, 1},
- %% Called (eventually) after needs_sync returns 'true'. Note this
- %% may be called more than once for each 'true' returned from
- %% needs_sync.
- {sync, 1},
+ %% Called (eventually) after needs_idle_timeout returns
+ %% 'true'. Note this may be called more than once for each 'true'
+ %% returned from needs_idle_timeout.
+ {idle_timeout, 1},
%% Called immediately before the queue hibernates.
{handle_pre_hibernate, 1},
diff --git a/src/rabbit_dialyzer.erl b/src/rabbit_dialyzer.erl
index 0ec6beb676..51bd6b1f93 100644
--- a/src/rabbit_dialyzer.erl
+++ b/src/rabbit_dialyzer.erl
@@ -56,7 +56,7 @@ create_basic_plt(BasicPltPath) ->
ok.
add_to_plt(PltPath, FilesString) ->
- {ok, Files} = regexp:split(FilesString, " "),
+ Files = string:tokens(FilesString, " "),
DialyzerWarnings = dialyzer:run([{analysis_type, plt_add},
{init_plt, PltPath},
{output_plt, PltPath},
@@ -65,7 +65,7 @@ add_to_plt(PltPath, FilesString) ->
ok.
dialyze_files(PltPath, ModifiedFiles) ->
- {ok, Files} = regexp:split(ModifiedFiles, " "),
+ Files = string:tokens(ModifiedFiles, " "),
DialyzerWarnings = dialyzer:run([{init_plt, PltPath},
{files, Files}]),
case DialyzerWarnings of
diff --git a/src/rabbit_exchange.erl b/src/rabbit_exchange.erl
index 67eaf8e691..1b9ec06732 100644
--- a/src/rabbit_exchange.erl
+++ b/src/rabbit_exchange.erl
@@ -49,7 +49,6 @@
-import(mnesia).
-import(sets).
-import(lists).
--import(regexp).
%%----------------------------------------------------------------------------
diff --git a/src/rabbit_exchange_type_topic.erl b/src/rabbit_exchange_type_topic.erl
index a374cfee7f..89b2441e38 100644
--- a/src/rabbit_exchange_type_topic.erl
+++ b/src/rabbit_exchange_type_topic.erl
@@ -67,8 +67,7 @@ publish(#exchange{name = Name}, Delivery =
Delivery).
split_topic_key(Key) ->
- {ok, KeySplit} = regexp:split(binary_to_list(Key), "\\."),
- KeySplit.
+ re:split(Key, "\\.", [{return, list}]).
topic_matches(PatternKey, RoutingKey) ->
P = split_topic_key(PatternKey),
diff --git a/src/rabbit_invariable_queue.erl b/src/rabbit_invariable_queue.erl
index 8214b976c4..4e0dad8422 100644
--- a/src/rabbit_invariable_queue.erl
+++ b/src/rabbit_invariable_queue.erl
@@ -34,10 +34,10 @@
-export([init/3, terminate/1, delete_and_terminate/1, purge/1, publish/2,
publish_delivered/3, fetch/2, ack/2, tx_publish/3, tx_ack/3,
tx_rollback/2, tx_commit/3, requeue/2, len/1, is_empty/1,
- set_ram_duration_target/2, ram_duration/1, needs_sync/1, sync/1,
- handle_pre_hibernate/1, status/1]).
+ set_ram_duration_target/2, ram_duration/1, needs_idle_timeout/1,
+ idle_timeout/1, handle_pre_hibernate/1, status/1]).
--export([start/1]).
+-export([start/1, stop/0]).
-behaviour(rabbit_backing_queue).
@@ -61,6 +61,9 @@
start(DurableQueues) ->
ok = rabbit_sup:start_child(rabbit_persister, [DurableQueues]).
+stop() ->
+ ok = rabbit_sup:stop_child(rabbit_persister).
+
init(QName, IsDurable, Recover) ->
Q = queue:from_list(case IsDurable andalso Recover of
true -> rabbit_persister:queue_content(QName);
@@ -197,9 +200,9 @@ set_ram_duration_target(_DurationTarget, State) -> State.
ram_duration(State) -> {0, State}.
-needs_sync(_State) -> false.
+needs_idle_timeout(_State) -> false.
-sync(State) -> State.
+idle_timeout(State) -> State.
handle_pre_hibernate(State) -> State.
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl
index fcc9fc7e54..9ed106d6fa 100644
--- a/src/rabbit_misc.erl
+++ b/src/rabbit_misc.erl
@@ -585,7 +585,7 @@ string_to_pid(Str) ->
binary_to_term(<<131,103,NodeEnc/binary,Id:32,Ser:32,0:8>>);
nomatch ->
throw(Err)
- end.
+ end.
version_compare(A, B, lte) ->
case version_compare(A, B) of
diff --git a/src/rabbit_multi.erl b/src/rabbit_multi.erl
index 5db1d77a32..3facef17f7 100644
--- a/src/rabbit_multi.erl
+++ b/src/rabbit_multi.erl
@@ -309,9 +309,9 @@ is_dead(Pid) ->
{win32, fun () ->
Res = os:cmd("tasklist /nh /fi \"pid eq " ++
PidS ++ "\""),
- case regexp:first_match(Res, "erl.exe") of
- {match, _, _} -> false;
- _ -> true
+ case re:run(Res, "erl\\.exe", [{capture, none}]) of
+ match -> false;
+ _ -> true
end
end}]).
diff --git a/src/rabbit_sup.erl b/src/rabbit_sup.erl
index 2c5e51125e..97613d17a5 100644
--- a/src/rabbit_sup.erl
+++ b/src/rabbit_sup.erl
@@ -34,7 +34,7 @@
-behaviour(supervisor).
-export([start_link/0, start_child/1, start_child/2, start_child/3,
- start_restartable_child/1, start_restartable_child/2]).
+ start_restartable_child/1, start_restartable_child/2, stop_child/1]).
-export([init/1]).
@@ -69,5 +69,11 @@ start_restartable_child(Mod, Args) ->
transient, infinity, supervisor, [rabbit_restartable_sup]}),
ok.
+stop_child(ChildId) ->
+ case supervisor:terminate_child(?SERVER, ChildId) of
+ ok -> supervisor:delete_child(?SERVER, ChildId);
+ E -> E
+ end.
+
init([]) ->
{ok, {{one_for_all, 0, 1}, []}}.
diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl
index ff7c07e37e..de06c048a2 100644
--- a/src/rabbit_tests.erl
+++ b/src/rabbit_tests.erl
@@ -1183,6 +1183,6 @@ handle_hook(HookName, Handler, Args) ->
A = atom_to_list(HookName) ++ "_" ++ atom_to_list(Handler) ++ "_fired",
put(list_to_atom(A), Args).
bad_handle_hook(_, _, _) ->
- bad:bad().
+ exit(bad_handle_hook_called).
extra_arg_hook(Hookname, Handler, Args, Extra1, Extra2) ->
handle_hook(Hookname, Handler, {Args, Extra1, Extra2}).