summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@rabbitmq.com>2012-10-12 19:32:26 +0100
committerMatthias Radestock <matthias@rabbitmq.com>2012-10-12 19:32:26 +0100
commit23f2939a49ebf6c08f6083a5aeb6b0f1f3caebf8 (patch)
treeb603f4f9d4812db1cbfd5e050cba41a6c75d3053
parent1bf6475b4e124c5790c87621030ea52bb15a7b07 (diff)
downloadrabbitmq-server-23f2939a49ebf6c08f6083a5aeb6b0f1f3caebf8.tar.gz
a spot of inlining
...and refactoring; exploiting the fact that maybe_record_confirm_message is a no-op when Confirm == never
-rw-r--r--src/rabbit_amqqueue_process.erl25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl
index 9706efbf..5ee7ca9a 100644
--- a/src/rabbit_amqqueue_process.erl
+++ b/src/rabbit_amqqueue_process.erl
@@ -554,19 +554,20 @@ deliver_or_enqueue(Delivery = #delivery{message = Message,
State) ->
Confirm = should_confirm_message(Delivery, State),
Props = message_properties(Confirm, Delivered, State),
- case attempt_delivery(Delivery, Props, State) of
+ case attempt_delivery(Delivery, Props,
+ maybe_record_confirm_message(Confirm, State)) of
{true, State1} ->
- maybe_record_confirm_message(Confirm, State1);
+ State1;
%% the next one is an optimisations
- %% TODO: optimise the Confirm =/= never case too
- {false, State1 = #q{ttl = 0, dlx = undefined}} when Confirm == never ->
- discard_delivery(Delivery, State1);
- {false, State1} ->
- State2 = #q{backing_queue = BQ, backing_queue_state = BQS} =
- maybe_record_confirm_message(Confirm, State1),
+ {false, State1 = #q{ttl = 0, dlx = undefined,
+ backing_queue = BQ, backing_queue_state = BQS}}
+ when Confirm == never ->
+ BQS1 = BQ:discard(Message, SenderPid, BQS),
+ State1#q{backing_queue_state = BQS1};
+ {false, State1 = #q{backing_queue = BQ, backing_queue_state = BQS}} ->
BQS1 = BQ:publish(Message, Props, SenderPid, BQS),
ensure_ttl_timer(Props#message_properties.expiry,
- State2#q{backing_queue_state = BQS1})
+ State1#q{backing_queue_state = BQS1})
end.
requeue_and_run(AckTags, State = #q{backing_queue = BQ,
@@ -683,12 +684,6 @@ subtract_acks(ChPid, AckTags, State, Fun) ->
Fun(State)
end.
-discard_delivery(#delivery{sender = SenderPid,
- message = Message},
- State = #q{backing_queue = BQ,
- backing_queue_state = BQS}) ->
- State#q{backing_queue_state = BQ:discard(Message, SenderPid, BQS)}.
-
message_properties(Confirm, Delivered, #q{ttl = TTL}) ->
#message_properties{expiry = calculate_msg_expiry(TTL),
needs_confirming = needs_confirming(Confirm),