summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2012-12-04 16:37:37 +0000
committerSimon MacMullen <simon@rabbitmq.com>2012-12-04 16:37:37 +0000
commit7246ac2347492a65ccd5d30cb4d65239e76eff27 (patch)
tree5a44c6e665e4af80bc29ea1d453bfe3c43f1f8be
parent5c30e7cf1fd1502ed5b30da8a6617705f27cd34f (diff)
downloadrabbitmq-server-7246ac2347492a65ccd5d30cb4d65239e76eff27.tar.gz
Send messages immediately if we are not busy.
-rw-r--r--src/gm.erl11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/gm.erl b/src/gm.erl
index 4a95de0d..1ee5f616 100644
--- a/src/gm.erl
+++ b/src/gm.erl
@@ -667,6 +667,10 @@ handle_info(flush, State) ->
noreply(
flush_broadcast_buffer(State #state { broadcast_timer = undefined }));
+handle_info(timeout, State) ->
+ noreply(
+ flush_broadcast_buffer(State #state { broadcast_timer = undefined }));
+
handle_info({'DOWN', MRef, process, _Pid, Reason},
State = #state { self = Self,
left = Left,
@@ -834,10 +838,13 @@ handle_msg({activity, _NotLeft, _Activity}, State) ->
noreply(State) ->
- {noreply, ensure_broadcast_timer(State), hibernate}.
+ {noreply, ensure_broadcast_timer(State), flush_timeout(State)}.
reply(Reply, State) ->
- {reply, Reply, ensure_broadcast_timer(State), hibernate}.
+ {reply, Reply, ensure_broadcast_timer(State), flush_timeout(State)}.
+
+flush_timeout(#state{broadcast_buffer = []}) -> hibernate;
+flush_timeout(_) -> 0.
ensure_broadcast_timer(State = #state { broadcast_buffer = [],
broadcast_timer = undefined }) ->