summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@rabbitmq.com>2011-01-13 02:16:18 +0000
committerMatthias Radestock <matthias@rabbitmq.com>2011-01-13 02:16:18 +0000
commit6a7d5447868f45d56fd31a1098a69ab5e891bd4e (patch)
tree454b420e8473302650dab2e0dbb56fcb30a70dfb
parent6a4b29d4761df133061f2da5908d2c288f5c9fe2 (diff)
downloadrabbitmq-server-6a7d5447868f45d56fd31a1098a69ab5e891bd4e.tar.gz
bug fix: don't send confirms when MsgSeqNo == undefined
also optimise unrouted message handling further - there is no point in going through all the logic of determining whether we can send a multi-ack since we know the MsgSeqNo will be the highest unconfirmed and it's just a single message we are confirming.
-rw-r--r--src/rabbit_channel.erl20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl
index dc160452..c5e523ec 100644
--- a/src/rabbit_channel.erl
+++ b/src/rabbit_channel.erl
@@ -1208,12 +1208,15 @@ is_message_persistent(Content) ->
process_routing_result(unroutable, _, MsgSeqNo, Message, State) ->
ok = basic_return(Message, State#ch.writer_pid, no_route),
- send_confirms([MsgSeqNo], State);
+ ok = send_confirm(MsgSeqNo, State#ch.writer_pid),
+ State;
process_routing_result(not_delivered, _, MsgSeqNo, Message, State) ->
ok = basic_return(Message, State#ch.writer_pid, no_consumers),
- send_confirms([MsgSeqNo], State);
+ ok = send_confirm(MsgSeqNo, State#ch.writer_pid),
+ State;
process_routing_result(routed, [], MsgSeqNo, _, State) ->
- send_confirms([MsgSeqNo], State);
+ ok = send_confirm(MsgSeqNo, State#ch.writer_pid),
+ State;
process_routing_result(routed, _, undefined, _, State) ->
State;
process_routing_result(routed, QPids, MsgSeqNo, _, State) ->
@@ -1242,12 +1245,15 @@ send_confirms(Cs, State = #ch{writer_pid = WriterPid, unconfirmed = UC}) ->
WriterPid, #'basic.ack'{delivery_tag = lists:last(Ms),
multiple = true})
end,
- ok = lists:foldl(fun(T, ok) ->
- rabbit_writer:send_command(
- WriterPid, #'basic.ack'{delivery_tag = T})
- end, ok, Ss),
+ [ok = send_confirm(SeqNo, WriterPid) || SeqNo <- Ss],
State.
+send_confirm(undefined, _WriterPid) ->
+ ok;
+send_confirm(SeqNo, WriterPid) ->
+ ok = rabbit_writer:send_command(WriterPid,
+ #'basic.ack'{delivery_tag = SeqNo}).
+
terminate(_State) ->
pg_local:leave(rabbit_channels, self()),
rabbit_event:notify(channel_closed, [{pid, self()}]).