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 | 97fd9e57030547b123c95bec56aacafde815cfb7 (patch) | |
tree | e64a8d25a8374ba6a94684953dcce1c64d63444d | |
parent | 841481da2c539a93d1689f809789f148902f6bec (diff) | |
download | rabbitmq-server-97fd9e57030547b123c95bec56aacafde815cfb7.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 2efb4e55..74d8c570 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. |