diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2014-01-22 15:03:36 +0000 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2014-01-22 15:03:36 +0000 |
commit | 9a80d2b11c339c8ee4d623719a66036f355d8cd4 (patch) | |
tree | fd73302e4e11cb248539c77da914c3e3ab70b769 /src/rabbit_channel.erl | |
parent | 77a1e73b85ac290cf55042537af5e7b8d7e39106 (diff) | |
download | rabbitmq-server-9a80d2b11c339c8ee4d623719a66036f355d8cd4.tar.gz |
Remove some duplication.
Diffstat (limited to 'src/rabbit_channel.erl')
-rw-r--r-- | src/rabbit_channel.erl | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl index 3ecb25f0..b5333788 100644 --- a/src/rabbit_channel.erl +++ b/src/rabbit_channel.erl @@ -348,17 +348,13 @@ handle_cast(force_event_refresh, State) -> rabbit_event:notify(channel_created, infos(?CREATION_EVENT_KEYS, State)), noreply(State); -%% TODO duplication? -handle_cast({mandatory_received, MsgSeqNo}, State = #ch{confirmed = C}) -> +handle_cast({mandatory_received, MsgSeqNo}, State) -> %% NB: don't call noreply/1 since we don't want to send confirms. - Timeout = case C of [] -> hibernate; _ -> 0 end, - {noreply, ensure_stats_timer(handle_mandatory(MsgSeqNo, State)), Timeout}; + noreply_coalesce(handle_mandatory(MsgSeqNo, State)); handle_cast({confirm, MsgSeqNos, From}, State) -> - State1 = #ch{confirmed = C} = confirm(MsgSeqNos, From, State), - Timeout = case C of [] -> hibernate; _ -> 0 end, %% NB: don't call noreply/1 since we don't want to send confirms. - {noreply, ensure_stats_timer(State1), Timeout}. + noreply_coalesce(confirm(MsgSeqNos, From, State)). handle_info({bump_credit, Msg}, State) -> credit_flow:handle_bump_msg(Msg), @@ -424,6 +420,10 @@ noreply(NewState) -> {noreply, next_state(NewState), hibernate}. next_state(State) -> ensure_stats_timer(send_confirms(State)). +noreply_coalesce(State = #ch{confirmed = C}) -> + Timeout = case C of [] -> hibernate; _ -> 0 end, + {noreply, ensure_stats_timer(State), Timeout}. + ensure_stats_timer(State) -> rabbit_event:ensure_stats_timer(State, #ch.stats_timer, emit_stats). |