diff options
| author | Matthias Radestock <matthias@lshift.net> | 2010-04-30 12:20:14 +0100 |
|---|---|---|
| committer | Matthias Radestock <matthias@lshift.net> | 2010-04-30 12:20:14 +0100 |
| commit | eab7e12334a3839e362c3ab762a5fd545f7f739c (patch) | |
| tree | 07e902d167601cdaaea8465466a67899a7e9bd2c /src | |
| parent | 2f64e75a56837113051974582b32189799dfade8 (diff) | |
| download | rabbitmq-server-git-eab7e12334a3839e362c3ab762a5fd545f7f739c.tar.gz | |
fix error handling in fhc:clear
and remove some wrong (though benign) code
Diffstat (limited to 'src')
| -rw-r--r-- | src/file_handle_cache.erl | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/file_handle_cache.erl b/src/file_handle_cache.erl index 7c156ac72e..2d326583ed 100644 --- a/src/file_handle_cache.erl +++ b/src/file_handle_cache.erl @@ -398,19 +398,16 @@ clear(Ref) -> [Ref], fun ([#handle { at_eof = true, write_buffer_size = 0, offset = 0 }]) -> ok; - ([Handle = #handle { write_buffer_size = Size, offset = Offset }]) -> - Handle1 = Handle #handle { write_buffer = [], - write_buffer_size = 0, - offset = Offset - Size }, - case maybe_seek(bof, Handle1) of - {{ok, 0}, Handle2 = #handle { hdl = Hdl }} -> + ([Handle]) -> + case maybe_seek(bof, Handle #handle { write_buffer = [], + write_buffer_size = 0 }) of + {{ok, 0}, Handle1 = #handle { hdl = Hdl }} -> case file:truncate(Hdl) of - ok -> {ok, [Handle2 #handle { - trusted_offset = 0, - at_eof = true }]}; - Error -> {Error, [Handle2]} + ok -> {ok, [Handle1 #handle {trusted_offset = 0, + at_eof = true }]}; + Error -> {Error, [Handle1]} end; - Error -> + {{error, _} = Error, Handle1} -> {Error, [Handle1]} end end). |
