diff options
| author | Matthew Sackman <matthew@lshift.net> | 2009-09-01 12:09:33 +0100 |
|---|---|---|
| committer | Matthew Sackman <matthew@lshift.net> | 2009-09-01 12:09:33 +0100 |
| commit | 590800c2b2711c79cc87981afc67b7f6d903532d (patch) | |
| tree | c0d7c7589a4aa50c2a1b104efeadce5c60dd5c47 /src | |
| parent | 8a5b3cdf7c705d3e8194af0ac32c52e2a9780db5 (diff) | |
| download | rabbitmq-server-git-590800c2b2711c79cc87981afc67b7f6d903532d.tar.gz | |
Read through all of Matthias changes, no problems. In here, one cosmetic, and one change so that rmf:read returns the MsgId off disk to be later matched. This is purely defensive.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_disk_queue.erl | 10 | ||||
| -rw-r--r-- | src/rabbit_msg_file.erl | 4 |
2 files changed, 5 insertions, 9 deletions
diff --git a/src/rabbit_disk_queue.erl b/src/rabbit_disk_queue.erl index 84c3b6e345..9caed89a5a 100644 --- a/src/rabbit_disk_queue.erl +++ b/src/rabbit_disk_queue.erl @@ -903,12 +903,12 @@ read_stored_message(#message_store_entry { msg_id = MsgId, ref_count = RefCount, total_size = TotalSize }, State) -> case fetch_and_increment_cache(MsgId, State) of not_found -> - {{ok, {MsgBody, _IsPersistent, _BodySize}}, State1} = + {{ok, {MsgId, MsgBody, _IsPersistent, _BodySize}}, State1} = with_read_handle_at( File, Offset, fun(Hdl) -> Res = case rabbit_msg_file:read(Hdl, TotalSize) of - {ok, {_, _, _}} = Obj -> Obj; + {ok, {MsgId, _, _, _}} = Obj -> Obj; {ok, Rest} -> throw({error, {misread, [{old_state, State}, @@ -1725,7 +1725,6 @@ load_messages(Left, [], State) -> current_offset = Offset }; load_messages(Left, [File|Files], State = #dqstate { file_summary = FileSummary }) -> - %% [{MsgId, TotalSize, FileOffset}] {ok, Messages} = scan_file_for_valid_messages(File), {ValidMessages, ValidTotalSize} = lists:foldl( fun (Obj = {MsgId, IsPersistent, TotalSize, Offset}, {VMAcc, VTSAcc}) -> @@ -1741,9 +1740,7 @@ load_messages(Left, [File|Files], file = File, offset = Offset, total_size = TotalSize, is_persistent = IsPersistent }), - {[Obj | VMAcc], - VTSAcc + TotalSize - } + {[Obj | VMAcc], VTSAcc + TotalSize} end end, {[], 0}, Messages), %% foldl reverses lists, find_contiguous_block_prefix needs @@ -1782,7 +1779,6 @@ scan_file_for_valid_messages_msg_ids(File) -> recover_crashed_compactions1(Files, TmpFile) -> NonTmpRelatedFile = filename:rootname(TmpFile) ++ ?FILE_EXTENSION, true = lists:member(NonTmpRelatedFile, Files), - %% [{MsgId, TotalSize, FileOffset}] {ok, UncorruptedMessagesTmp, MsgIdsTmp} = scan_file_for_valid_messages_msg_ids(TmpFile), %% all of these messages should appear in the mnesia table, diff --git a/src/rabbit_msg_file.erl b/src/rabbit_msg_file.erl index 6cf11ac871..70b04c0900 100644 --- a/src/rabbit_msg_file.erl +++ b/src/rabbit_msg_file.erl @@ -70,13 +70,13 @@ read(FileHdl, TotalSize) -> MsgIdBinSize:?INTEGER_SIZE_BITS, Rest:SizeWriteOkBytes/binary>>} -> BodySize = Size - MsgIdBinSize, - <<_MsgId:MsgIdBinSize/binary, MsgBody:BodySize/binary, + <<MsgId:MsgIdBinSize/binary, MsgBody:BodySize/binary, StopByte:?WRITE_OK_SIZE_BITS>> = Rest, Persistent = case StopByte of ?WRITE_OK_TRANSIENT -> false; ?WRITE_OK_PERSISTENT -> true end, - {ok, {MsgBody, Persistent, BodySize}}; + {ok, {binary_to_term(MsgId), MsgBody, Persistent, BodySize}}; KO -> KO end. |
