summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@lshift.net>2009-10-05 18:11:02 +0100
committerMatthew Sackman <matthew@lshift.net>2009-10-05 18:11:02 +0100
commit2fbcc4c836a824a5a56fbc7f1ddb943ab49b05bb (patch)
tree108494da3ff0987eca7180f58b3cde704c94a065 /src
parent234628c76a7269d8f8cad7def3fea39ff8bacd11 (diff)
downloadrabbitmq-server-git-2fbcc4c836a824a5a56fbc7f1ddb943ab49b05bb.tar.gz
mainly cosmetics
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_file_handle_cache2.erl22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/rabbit_file_handle_cache2.erl b/src/rabbit_file_handle_cache2.erl
index 6594e62f45..c15a3087a6 100644
--- a/src/rabbit_file_handle_cache2.erl
+++ b/src/rabbit_file_handle_cache2.erl
@@ -89,12 +89,11 @@ get_file_handle(Path, Mode, CState = #client_state { handles = Handles }) ->
release_file_handle({release_handle, Key = {_From, Path, Mode}},
CState = #client_state { handles = Handles }) ->
- Mode1 = lists:usort(Mode),
- case dict:find({Path, Mode1}, Handles) of
+ case dict:find({Path, Mode}, Handles) of
error -> %% oh well, it must have already gone
CState;
{value, {_Hdl, Offset}} ->
- Handles1 = dict:erase({Path, Mode1}, Handles),
+ Handles1 = dict:erase({Path, Mode}, Handles),
gen_server2:cast(?SERVER, {release_handle, Key, Offset}),
CState #client_state { handles = Handles1 }
end.
@@ -113,13 +112,14 @@ with_file_handle_at(Path, Mode, Offset, Fun, CState =
case obtain_file_handle(Path, Mode, CState) of
not_available -> {not_available, CState};
{Mode1, Hdl, OldOffset} ->
- SeekRes = case Offset == OldOffset of
- true -> ok;
- false -> case file:position(Hdl, Offset) of
- {ok, _} -> ok;
- KO -> KO
- end
- end,
+ SeekRes =
+ case Offset == OldOffset orelse not is_integer(Offset) of
+ true -> ok;
+ false -> case file:position(Hdl, Offset) of
+ {ok, _} -> ok;
+ KO -> KO
+ end
+ end,
case SeekRes of
ok -> {NewOffset, Result} = Fun(Hdl),
{Result, CState #client_state {
@@ -164,7 +164,7 @@ init([MaxFileHandles]) ->
handle_call(new_client, From, State) ->
_MRef = erlang:monitor(process, From),
- {reply, ok, State};
+ {reply, ok, State, hibernate};
handle_call({get_handle, Path, Mode, Callback = {_M, _F, _A}}, From,
State = #server_state { handles = Handles,
ages = Ages,