diff options
| author | Matthew Sackman <matthew@lshift.net> | 2010-04-04 01:40:53 +0100 |
|---|---|---|
| committer | Matthew Sackman <matthew@lshift.net> | 2010-04-04 01:40:53 +0100 |
| commit | fb912a1f7f078c9848c3b1bf6cadd1d5280e5c1e (patch) | |
| tree | 48750d6be59f75ec8b41edb77e097fba43caee2f /src | |
| parent | b1028e1a249dbc3e1f2df8d17f48bba374ff678c (diff) | |
| download | rabbitmq-server-git-fb912a1f7f078c9848c3b1bf6cadd1d5280e5c1e.tar.gz | |
Mistake in opening files leading to process dictionary being wrongly populated and updated when file opening fails (eg enoent)
Diffstat (limited to 'src')
| -rw-r--r-- | src/file_handle_cache.erl | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/file_handle_cache.erl b/src/file_handle_cache.erl index 520be0ce2e..c43695fbd8 100644 --- a/src/file_handle_cache.erl +++ b/src/file_handle_cache.erl @@ -230,26 +230,26 @@ open(Path, Mode, Options) -> File1 = #file { reader_count = RCount, has_writer = HasWriter } = case get({Path1, fhc_file}) of File = #file {} -> File; - undefined -> File = #file { reader_count = 0, - has_writer = false }, - put({Path1, fhc_file}, File), - File + undefined -> #file { reader_count = 0, + has_writer = false } end, IsWriter = is_writer(Mode), case IsWriter andalso HasWriter of true -> {error, writer_exists}; - false -> RCount1 = case is_reader(Mode) of - true -> RCount + 1; - false -> RCount - end, - HasWriter1 = HasWriter orelse IsWriter, - put({Path1, fhc_file}, - File1 #file { reader_count = RCount1, - has_writer = HasWriter1}), - Ref = make_ref(), + false -> Ref = make_ref(), case open1(Path1, Mode, Options, Ref, bof, new) of - {ok, _Handle} -> {ok, Ref}; - Error -> Error + {ok, _Handle} -> + RCount1 = case is_reader(Mode) of + true -> RCount + 1; + false -> RCount + end, + HasWriter1 = HasWriter orelse IsWriter, + put({Path1, fhc_file}, + File1 #file { reader_count = RCount1, + has_writer = HasWriter1}), + {ok, Ref}; + Error -> + Error end end end. |
