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 | 79e6a959e132a14ab9cfd497149c446fd18be140 (patch) | |
| tree | 13f7f0ebd2ddb036a975d24d87d480971fc6eb1a | |
| parent | 2ba43b47431249ef7d5ec79941bbc1a7c5ca050c (diff) | |
| download | rabbitmq-server-git-79e6a959e132a14ab9cfd497149c446fd18be140.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 160512a248..e74211af4b 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( |
