summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@rabbitmq.com>2010-09-09 07:19:27 +0100
committerMatthias Radestock <matthias@rabbitmq.com>2010-09-09 07:19:27 +0100
commit31375181ad7b0a43309da655dbdbfe885d2805a0 (patch)
treed7cb07bb58ec20916177ee33d1b2d7c45ca86cb4
parentfaa904d064f9f65ae21dd4a5c366b08eb9ab3d71 (diff)
downloadrabbitmq-server-git-31375181ad7b0a43309da655dbdbfe885d2805a0.tar.gz
minor refactor
-rw-r--r--src/rabbit_msg_store.erl16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/rabbit_msg_store.erl b/src/rabbit_msg_store.erl
index bfec82c5e3..0a80f8faab 100644
--- a/src/rabbit_msg_store.erl
+++ b/src/rabbit_msg_store.erl
@@ -619,8 +619,7 @@ handle_cast({write, Guid},
case Locked of
true -> ok = index_delete(Guid, State),
write_message(Guid, Msg, 1, State);
- false -> ok = index_update_fields(
- Guid, {#msg_location.ref_count, 1}, State),
+ false -> ok = index_update_ref_count(Guid, 1, State),
ok = add_to_file_summary(Summary, TotalSize, FileSize,
State),
noreply(State #msstate {
@@ -629,9 +628,7 @@ handle_cast({write, Guid},
#msg_location { ref_count = RefCount } ->
%% We already know about it, just update counter. Only
%% update field otherwise bad interaction with concurrent GC
- ok = index_update_fields(Guid,
- {#msg_location.ref_count, RefCount + 1},
- State),
+ ok = index_update_ref_count(Guid, RefCount + 1, State),
noreply(State)
end;
@@ -915,9 +912,7 @@ remove_message(Guid, State = #msstate { sum_valid_data = SumValid,
total_size = TotalSize } =
index_lookup_positive_refcount(Guid, State),
%% only update field, otherwise bad interaction with concurrent GC
- Dec = fun () -> index_update_fields(
- Guid, {#msg_location.ref_count, RefCount - 1}, State)
- end,
+ Dec = fun () -> index_update_ref_count(Guid, RefCount - 1, State) end,
case RefCount of
%% don't remove from CUR_FILE_CACHE_ETS_NAME here because
%% there may be further writes in the mailbox for the same
@@ -928,7 +923,7 @@ remove_message(Guid, State = #msstate { sum_valid_data = SumValid,
ets:lookup(FileSummaryEts, File),
case Locked of
true -> add_to_pending_gc_completion({remove, Guid}, State);
- false -> ok = Dec(),
+ false -> Dec(),
true = ets:update_element(
FileSummaryEts, File,
[{#file_summary.valid_total_size,
@@ -1118,6 +1113,9 @@ index_lookup_positive_refcount(Key, State) ->
#msg_location {} = MsgLocation -> MsgLocation
end.
+index_update_ref_count(Key, RefCount, State) ->
+ index_update_fields(Key, {#msg_location.ref_count, RefCount}, State).
+
index_lookup(Key, #client_msstate { index_module = Index,
index_state = State }) ->
Index:lookup(Key, State);