diff options
| author | Matthias Radestock <matthias@rabbitmq.com> | 2010-08-22 19:53:11 +0100 |
|---|---|---|
| committer | Matthias Radestock <matthias@rabbitmq.com> | 2010-08-22 19:53:11 +0100 |
| commit | 943ff78e662e89ed6347ba2372a0057b1e0f6b57 (patch) | |
| tree | e64a8d25a8374ba6a94684953dcce1c64d63444d | |
| parent | bf24a9107181ddd475b3a094fbef315d3fd5f83a (diff) | |
| download | rabbitmq-server-git-943ff78e662e89ed6347ba2372a0057b1e0f6b57.tar.gz | |
ensure and assert that closed handles have last_used_at=undefined
That way it is more obvious which handles should be in the age tree
and which shouldn't.
| -rw-r--r-- | src/file_handle_cache.erl | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/file_handle_cache.erl b/src/file_handle_cache.erl index 2efb4e5524..74d8c5706f 100644 --- a/src/file_handle_cache.erl +++ b/src/file_handle_cache.erl @@ -550,10 +550,11 @@ reopen(ClosedHdls) -> reopen(ClosedHdls, get_age_tree(), []). reopen([], Tree, RefHdls) -> put_age_tree(Tree), {ok, lists:reverse(RefHdls)}; -reopen([{Ref, NewOrReopen, Handle = #handle { hdl = closed, - path = Path, - mode = Mode, - offset = Offset }} | +reopen([{Ref, NewOrReopen, Handle = #handle { hdl = closed, + path = Path, + mode = Mode, + offset = Offset, + last_used_at = undefined }} | RefNewOrReopenHdls] = ToOpen, Tree, RefHdls) -> case file:open(Path, case NewOrReopen of new -> Mode; @@ -680,7 +681,9 @@ soft_close(Handle = #handle { hdl = closed }) -> {ok, Handle}; soft_close(Handle) -> case write_buffer(Handle) of - {ok, #handle { hdl = Hdl, offset = Offset, is_dirty = IsDirty, + {ok, #handle { hdl = Hdl, + offset = Offset, + is_dirty = IsDirty, last_used_at = Then } = Handle1 } -> ok = case IsDirty of true -> file:sync(Hdl); @@ -688,8 +691,10 @@ soft_close(Handle) -> end, ok = file:close(Hdl), age_tree_delete(Then), - {ok, Handle1 #handle { hdl = closed, trusted_offset = Offset, - is_dirty = false }}; + {ok, Handle1 #handle { hdl = closed, + trusted_offset = Offset, + is_dirty = false, + last_used_at = undefined }}; {_Error, _Handle} = Result -> Result end. |
