summaryrefslogtreecommitdiff
path: root/src/rabbit_reader.erl
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@rabbitmq.com>2013-12-12 12:42:05 +0000
committerMatthias Radestock <matthias@rabbitmq.com>2013-12-12 12:42:05 +0000
commit8efdeb608237d9a3d578a5cf38002de40e32439c (patch)
tree8da451d1d248efb54de5aef686a7dd2149778ab3 /src/rabbit_reader.erl
parent62dbe65cf0083c2b5eef49bf047a7d0c54f12b09 (diff)
downloadrabbitmq-server-8efdeb608237d9a3d578a5cf38002de40e32439c.tar.gz
refactor: take advantage of channel_count to simplify terminate_channels
Diffstat (limited to 'src/rabbit_reader.erl')
-rw-r--r--src/rabbit_reader.erl16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/rabbit_reader.erl b/src/rabbit_reader.erl
index 64d5cf2a..a41171a1 100644
--- a/src/rabbit_reader.erl
+++ b/src/rabbit_reader.erl
@@ -499,15 +499,13 @@ handle_dependent_exit(ChPid, Reason, State) ->
maybe_close(control_throttle(State2))
end.
-terminate_channels(State) ->
- NChannels =
- length([rabbit_channel:shutdown(ChPid) || ChPid <- all_channels()]),
- if NChannels > 0 ->
- Timeout = 1000 * ?CHANNEL_TERMINATION_TIMEOUT * NChannels,
- TimerRef = erlang:send_after(Timeout, self(), cancel_wait),
- wait_for_channel_termination(NChannels, TimerRef, State);
- true -> State
- end.
+terminate_channels(#v1{channel_count = 0} = State) ->
+ State;
+terminate_channels(#v1{channel_count = ChannelCount} = State) ->
+ lists:foreach(fun rabbit_channel:shutdown/1, all_channels()),
+ Timeout = 1000 * ?CHANNEL_TERMINATION_TIMEOUT * ChannelCount,
+ TimerRef = erlang:send_after(Timeout, self(), cancel_wait),
+ wait_for_channel_termination(ChannelCount, TimerRef, State).
wait_for_channel_termination(0, TimerRef, _State) ->
case erlang:cancel_timer(TimerRef) of