summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@lshift.net>2010-04-04 03:23:02 +0100
committerMatthew Sackman <matthew@lshift.net>2010-04-04 03:23:02 +0100
commit51cfb3b2ce5a82861b1f43182067e1c41420dcb0 (patch)
treea87a8e78680c57c1a8a44e384a5dfa52956c8351
parentfb912a1f7f078c9848c3b1bf6cadd1d5280e5c1e (diff)
downloadrabbitmq-server-git-51cfb3b2ce5a82861b1f43182067e1c41420dcb0.tar.gz
If we submit to the workers jobs which use the fhc, the workers may receive messages from the fhc, thus need to be able to process them. Also, that then requires that the fhc is started before the workers
-rw-r--r--src/rabbit.erl12
-rw-r--r--src/worker_pool_worker.erl15
2 files changed, 20 insertions, 7 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl
index 387b3256bb..de2fec574c 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -53,6 +53,12 @@
[{mfa, {rabbit_mnesia, init, []}},
{enables, external_infrastructure}]}).
+-rabbit_boot_step({file_handle_cache,
+ [{description, "file handle cache server"},
+ {mfa, {rabbit_sup, start_restartable_child,
+ [file_handle_cache]}},
+ {enables, worker_pool}]}).
+
-rabbit_boot_step({worker_pool,
[{description, "worker pool"},
{mfa, {rabbit_sup, start_child, [worker_pool_sup]}},
@@ -81,12 +87,6 @@
{enables, kernel_ready},
{requires, external_infrastructure}]}).
--rabbit_boot_step({file_handle_cache,
- [{description, "file handle cache server"},
- {mfa, {rabbit_sup, start_restartable_child,
- [file_handle_cache]}},
- {enables, kernel_ready}]}).
-
-rabbit_boot_step({kernel_ready,
[{description, "kernel ready"},
{requires, external_infrastructure}]}).
diff --git a/src/worker_pool_worker.erl b/src/worker_pool_worker.erl
index 4defc5bafe..5a6ccb1609 100644
--- a/src/worker_pool_worker.erl
+++ b/src/worker_pool_worker.erl
@@ -35,6 +35,8 @@
-export([start_link/1, submit/2, submit_async/2, run/1]).
+-export([set_maximum_since_use/2]).
+
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).
@@ -64,7 +66,14 @@ submit(Pid, Fun) ->
submit_async(Pid, Fun) ->
gen_server2:cast(Pid, {submit_async, Fun}).
+set_maximum_since_use(Pid, Age) ->
+ gen_server2:pcast(Pid, 8, {set_maximum_since_use, Age}).
+
+%%----------------------------------------------------------------------------
+
init([WId]) ->
+ ok = file_handle_cache:register_callback(?MODULE, set_maximum_since_use,
+ [self()]),
ok = worker_pool:idle(WId),
put(worker_pool_worker, true),
{ok, WId, hibernate,
@@ -81,7 +90,11 @@ handle_call(Msg, _From, State) ->
handle_cast({submit_async, Fun}, WId) ->
run(Fun),
ok = worker_pool:idle(WId),
- {noreply, WId};
+ {noreply, WId, hibernate};
+
+handle_cast({set_maximum_since_use, Age}, WId) ->
+ ok = file_handle_cache:set_maximum_since_use(Age),
+ {noreply, WId, hibernate};
handle_cast(Msg, State) ->
{stop, {unexpected_cast, Msg}, State}.