summaryrefslogtreecommitdiff
path: root/src
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
commit82e9671524a2620869807b028906a771b46bdcfe (patch)
tree256e0823028debc2290b05f3886463356c0580d5 /src
parent68acf42bd81a7db4d30605a4c5f99fdc48c4f9d9 (diff)
downloadrabbitmq-server-git-82e9671524a2620869807b028906a771b46bdcfe.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.
Diffstat (limited to 'src')
-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 6c08520fd2..8a6826162f 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 b867223b50..8872690092 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 cc65c5699b..767e4adc33 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() ->