diff options
| author | Matthew Sackman <matthew@lshift.net> | 2010-04-30 13:22:16 +0100 |
|---|---|---|
| committer | Matthew Sackman <matthew@lshift.net> | 2010-04-30 13:22:16 +0100 |
| commit | 2c9320f061a83adca550597f2a69afb698efe331 (patch) | |
| tree | 11d0eb6b304d62946cdbdbd70a777314fb2c67ba /src | |
| parent | dbf7bd2c0d6f3725c295d2ee1288755ec279ea00 (diff) | |
| download | rabbitmq-server-git-2c9320f061a83adca550597f2a69afb698efe331.tar.gz | |
Don't allow lots of timers to be started
Diffstat (limited to 'src')
| -rw-r--r-- | src/file_handle_cache.erl | 20 | ||||
| -rw-r--r-- | src/rabbit_tests.erl | 1 |
2 files changed, 14 insertions, 7 deletions
diff --git a/src/file_handle_cache.erl b/src/file_handle_cache.erl index adcff653d2..7d96b66f22 100644 --- a/src/file_handle_cache.erl +++ b/src/file_handle_cache.erl @@ -170,7 +170,8 @@ limit, count, obtains, - callbacks_mrefs + callbacks_mrefs, + reduce_timer_set }). %%---------------------------------------------------------------------------- @@ -698,7 +699,8 @@ init([]) -> end, error_logger:info_msg("Limiting to approx ~p file handles~n", [Limit]), {ok, #fhc_state { elders = dict:new(), limit = Limit, count = 0, - obtains = [], callbacks_mrefs = dict:new() }}. + obtains = [], callbacks_mrefs = dict:new(), + reduce_timer_set = false }}. handle_call(obtain, From, State = #fhc_state { count = Count }) -> State1 = #fhc_state { count = Count1, limit = Limit, obtains = Obtains } = @@ -743,7 +745,7 @@ handle_cast({close, Pid, EldestUnusedSince}, State = count = Count - 1 }))}; handle_cast(check_counts, State) -> - {noreply, maybe_reduce(State)}; + {noreply, maybe_reduce(State #fhc_state { reduce_timer_set = false })}; handle_cast({release_on_death, Pid}, State) -> _MRef = erlang:monitor(process, Pid), @@ -788,7 +790,7 @@ process_obtains(State = #fhc_state { limit = Limit, count = Count, maybe_reduce(State = #fhc_state { limit = Limit, count = Count, elders = Elders, - callbacks_mrefs = CallsMRefs }) + callbacks_mrefs = CallsMRefs, reduce_timer_set = TimerSet }) when Limit /= infinity andalso Count >= Limit -> Now = now(), {Pids, Sum, ClientCount} = @@ -811,9 +813,13 @@ maybe_reduce(State = #fhc_state { end end, Pids) end, - {ok, _TRef} = timer:apply_after(?FILE_HANDLES_CHECK_INTERVAL, - gen_server, cast, [?SERVER, check_counts]), - State; + case TimerSet of + true -> State; + false -> {ok, _TRef} = timer:apply_after( + ?FILE_HANDLES_CHECK_INTERVAL, + gen_server, cast, [?SERVER, check_counts]), + State #fhc_state { reduce_timer_set = true } + end; maybe_reduce(State) -> State. diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl index b99634002b..3cac429e4c 100644 --- a/src/rabbit_tests.erl +++ b/src/rabbit_tests.erl @@ -54,6 +54,7 @@ test_content_prop_roundtrip(Datum, Binary) -> Binary = rabbit_binary_generator:encode_properties(Types, Values). %% assertion all_tests() -> + application:set_env(rabbit, file_handles_high_watermark, 10, infinity), passed = test_backing_queue(), passed = test_priority_queue(), passed = test_bpqueue(), |
