summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Watson <watson.timothy@gmail.com>2014-04-08 13:55:36 +0100
committerTim Watson <watson.timothy@gmail.com>2014-04-08 13:55:36 +0100
commit021819d55ad25b563bdb75ade2c796a756ea4ebb (patch)
tree256e0823028debc2290b05f3886463356c0580d5
parentc2ad129d241492576f039419e83dcc53ed4f0f5c (diff)
downloadrabbitmq-server-021819d55ad25b563bdb75ade2c796a756ea4ebb.tar.gz
Fix management extension enable/disable handling
When notifying about 'enabled' plugins, limit to explicitly given. When handling 'disabled' plugins, call the event handler(s) synchronously (while we still have loaded modules) prior to stopping and unloading any apps.
-rw-r--r--src/rabbit.erl6
-rw-r--r--src/rabbit_event.erl24
-rw-r--r--src/rabbit_plugins.erl8
3 files changed, 28 insertions, 10 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl
index 6c08520f..8a682616 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -210,6 +210,7 @@
%% this really should be an abstract type
-type(log_location() :: 'tty' | 'undefined' | file:filename()).
-type(param() :: atom()).
+-type(app_name() :: atom()).
-spec(start/0 :: () -> 'ok').
-spec(boot/0 :: () -> 'ok').
@@ -241,6 +242,8 @@
-spec(maybe_insert_default_data/0 :: () -> 'ok').
-spec(boot_delegate/0 :: () -> 'ok').
-spec(recover/0 :: () -> 'ok').
+-spec(start_apps/1 :: ([app_name()]) -> 'ok').
+-spec(stop_apps/1 :: ([app_name()]) -> 'ok').
-endif.
@@ -350,8 +353,7 @@ start_apps(Apps) ->
_ -> ok
end,
ok = app_utils:start_applications(StartupApps,
- handle_app_error(could_not_start)),
- StartupApps.
+ handle_app_error(could_not_start)).
start_it(StartFun) ->
Marker = spawn_link(fun() -> receive stop -> ok end end),
diff --git a/src/rabbit_event.erl b/src/rabbit_event.erl
index b867223b..88726900 100644
--- a/src/rabbit_event.erl
+++ b/src/rabbit_event.erl
@@ -23,6 +23,7 @@
ensure_stats_timer/3, stop_stats_timer/2, reset_stats_timer/2]).
-export([stats_level/2, if_enabled/3]).
-export([notify/2, notify/3, notify_if/3]).
+-export([sync_notify/2, sync_notify/3]).
%%----------------------------------------------------------------------------
@@ -61,6 +62,9 @@
-spec(notify/2 :: (event_type(), event_props()) -> 'ok').
-spec(notify/3 :: (event_type(), event_props(), reference() | 'none') -> 'ok').
-spec(notify_if/3 :: (boolean(), event_type(), event_props()) -> 'ok').
+-spec(sync_notify/2 :: (event_type(), event_props()) -> 'ok').
+-spec(sync_notify/3 :: (event_type(), event_props(),
+ reference() | 'none') -> 'ok').
-endif.
@@ -145,7 +149,19 @@ notify_if(false, _Type, _Props) -> ok.
notify(Type, Props) -> notify(Type, Props, none).
notify(Type, Props, Ref) ->
- gen_event:notify(?MODULE, #event{type = Type,
- props = Props,
- reference = Ref,
- timestamp = os:timestamp()}).
+ do_notify(notify, #event{type = Type,
+ props = Props,
+ reference = Ref,
+ timestamp = os:timestamp()}).
+
+sync_notify(Type, Props) -> sync_notify(Type, Props, none).
+
+sync_notify(Type, Props, Ref) ->
+ do_notify(sync_notify, #event{ type = Type,
+ props = Props,
+ reference = Ref,
+ timestamp = os:timestamp()}).
+
+do_notify(F, Event) ->
+ apply(gen_event, F, [?MODULE, Event]).
+
diff --git a/src/rabbit_plugins.erl b/src/rabbit_plugins.erl
index cc65c569..767e4adc 100644
--- a/src/rabbit_plugins.erl
+++ b/src/rabbit_plugins.erl
@@ -40,15 +40,15 @@
enable(Plugins) ->
prepare_plugins(Plugins),
- Diff = rabbit:start_apps(Plugins),
- ok = rabbit_event:notify(plugins_changed, [{enabled, Diff}]).
+ rabbit:start_apps(Plugins),
+ ok = rabbit_event:notify(plugins_changed, [{enabled, Plugins}]).
disable(Plugins) ->
RunningApps = rabbit_misc:which_applications(),
ToDisable = [P || P <- Plugins,
proplists:is_defined(P, RunningApps)],
- rabbit:stop_apps(ToDisable),
- ok = rabbit_event:notify(plugins_changed, [{disabled, ToDisable}]).
+ ok = rabbit_event:sync_notify(plugins_changed, [{disabled, ToDisable}]),
+ rabbit:stop_apps(ToDisable).
%% @doc Prepares the file system and installs all enabled plugins.
setup() ->