diff options
author | Emile Joubert <emile@rabbitmq.com> | 2010-09-28 16:41:23 +0100 |
---|---|---|
committer | Emile Joubert <emile@rabbitmq.com> | 2010-09-28 16:41:23 +0100 |
commit | f2e188bbc4a9d8a3cc147275427adb284d5f0505 (patch) | |
tree | 38d9af001030ebc782ff259fb63cd13d6f1f5d6b | |
parent | fda5c56a453f6ffee62299fb0ade9c7d636d61dc (diff) | |
parent | 02a98db3e0f896665d129777f44ff3abcdd76c61 (diff) | |
download | rabbitmq-server-f2e188bbc4a9d8a3cc147275427adb284d5f0505.tar.gz |
Merged bug23310 into default
-rw-r--r-- | src/rabbit_queue_index.erl | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/rabbit_queue_index.erl b/src/rabbit_queue_index.erl index 3ee461bf..0b98290c 100644 --- a/src/rabbit_queue_index.erl +++ b/src/rabbit_queue_index.erl @@ -159,7 +159,9 @@ -define(PUB, {_, _}). %% {Guid, IsPersistent} --define(READ_MODE, [binary, raw, read, {read_ahead, ?SEGMENT_TOTAL_SIZE}]). +-define(READ_MODE, [binary, raw, read]). +-define(READ_AHEAD_MODE, [{read_ahead, ?SEGMENT_TOTAL_SIZE} | ?READ_MODE]). +-define(WRITE_MODE, [write | ?READ_MODE]). %%---------------------------------------------------------------------------- @@ -580,7 +582,7 @@ append_journal_to_segment(#segment { journal_entries = JEntries, path = Path } = Segment) -> case array:sparse_size(JEntries) of 0 -> Segment; - _ -> {ok, Hdl} = file_handle_cache:open(Path, [write | ?READ_MODE], + _ -> {ok, Hdl} = file_handle_cache:open(Path, ?WRITE_MODE, [{write_buffer, infinity}]), array:sparse_foldl(fun write_entry_to_segment/3, Hdl, JEntries), ok = file_handle_cache:close(Hdl), @@ -591,7 +593,7 @@ get_journal_handle(State = #qistate { journal_handle = undefined, dir = Dir }) -> Path = filename:join(Dir, ?JOURNAL_FILENAME), ok = filelib:ensure_dir(Path), - {ok, Hdl} = file_handle_cache:open(Path, [write | ?READ_MODE], + {ok, Hdl} = file_handle_cache:open(Path, ?WRITE_MODE, [{write_buffer, infinity}]), {Hdl, State #qistate { journal_handle = Hdl }}; get_journal_handle(State = #qistate { journal_handle = Hdl }) -> @@ -788,7 +790,7 @@ segment_entries_foldr(Fun, Init, load_segment(KeepAcked, #segment { path = Path }) -> case filelib:is_file(Path) of false -> {array_new(), 0}; - true -> {ok, Hdl} = file_handle_cache:open(Path, ?READ_MODE, []), + true -> {ok, Hdl} = file_handle_cache:open(Path, ?READ_AHEAD_MODE, []), {ok, 0} = file_handle_cache:position(Hdl, bof), Res = load_segment_entries(KeepAcked, Hdl, array_new(), 0), ok = file_handle_cache:close(Hdl), |