diff options
author | Matthias Radestock <matthias@rabbitmq.com> | 2013-02-11 12:01:18 +0000 |
---|---|---|
committer | Matthias Radestock <matthias@rabbitmq.com> | 2013-02-11 12:01:18 +0000 |
commit | d4b5bfd64c43191bab8c13c122e57981c6c2eee6 (patch) | |
tree | 13f7f0ebd2ddb036a975d24d87d480971fc6eb1a | |
parent | 7fda39b54ccb1bfbf1082d633b10eae4bf2bd954 (diff) | |
download | rabbitmq-server-d4b5bfd64c43191bab8c13c122e57981c6c2eee6.tar.gz |
a little bit of refactoring of channel.flow code
-rw-r--r-- | src/rabbit_channel.erl | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl index 160512a2..e74211af 100644 --- a/src/rabbit_channel.erl +++ b/src/rabbit_channel.erl @@ -544,14 +544,17 @@ check_name(_Kind, NameBin) -> queue_blocked(QPid, State = #ch{blocking = Blocking}) -> case sets:is_element(QPid, Blocking) of false -> State; - true -> Blocking1 = sets:del_element(QPid, Blocking), - case sets:size(Blocking1) of - 0 -> ok = send(#'channel.flow_ok'{active = false}, State); - _ -> ok - end, - State#ch{blocking = Blocking1} + true -> maybe_send_flow_ok( + State#ch{blocking = sets:del_element(QPid, Blocking)}) end. +maybe_send_flow_ok(State = #ch{blocking = Blocking}) -> + case sets:size(Blocking) of + 0 -> ok = send(#'channel.flow_ok'{active = false}, State); + _ -> ok + end, + State. + record_confirms([], State) -> State; record_confirms(MXs, State = #ch{confirmed = C}) -> @@ -1082,12 +1085,9 @@ handle_method(#'channel.flow'{active = false}, _, end, State1 = State#ch{limiter = Limiter1}, ok = rabbit_limiter:block(Limiter1), - case consumer_queues(Consumers) of - [] -> {reply, #'channel.flow_ok'{active = false}, State1}; - QPids -> State2 = State1#ch{blocking = sets:from_list(QPids)}, - ok = rabbit_amqqueue:flush_all(QPids, self()), - {noreply, State2} - end; + QPids = consumer_queues(Consumers), + ok = rabbit_amqqueue:flush_all(QPids, self()), + {noreply, maybe_send_flow_ok(State1#ch{blocking = sets:from_list(QPids)})}; handle_method(_MethodRecord, _Content, _State) -> rabbit_misc:protocol_error( |