From 4efa0e92e8ab33daf9fc502e8cd036cee3019ce0 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Thu, 19 Aug 2010 12:28:48 +0100 Subject: once again allow use of fhc w/o registering --- src/file_handle_cache.erl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/file_handle_cache.erl b/src/file_handle_cache.erl index e51ce921..dd693cb4 100644 --- a/src/file_handle_cache.erl +++ b/src/file_handle_cache.erl @@ -751,8 +751,9 @@ handle_call({open, Pid, EldestUnusedSince, CanClose}, From, elders = Elders }) -> Elders1 = dict:store(Pid, EldestUnusedSince, Elders), Item = {open, Pid, From}, - case maybe_reduce(State #fhc_state { open_count = Count + 1, - elders = Elders1 }) of + case maybe_reduce(ensure_mref(Pid, State #fhc_state { + open_count = Count + 1, + elders = Elders1 })) of {true, State1} -> State2 = State1 #fhc_state { open_count = Count }, case CanClose of @@ -933,8 +934,10 @@ maybe_reduce(State = #fhc_state { limit = Limit, _ -> AverageAge = Sum / ClientCount, lists:foreach( fun (Pid) -> - {M, F, A} = dict:fetch(Pid, Callbacks), - apply(M, F, A ++ [AverageAge]) + case dict:find(Pid, Callbacks) of + error -> ok; + {ok, {M, F, A}} -> apply(M, F, A ++ [AverageAge]) + end end, Pids) end, AboveLimit = Limit =/= infinity andalso OpenCount + ObtainCount > Limit, -- cgit v1.2.1