Blame rabbitmq-server-0001-Make-slaves-wait-timeout-configurable-instead-of-har.patch

3f8d36
From: Peter Lemenkov <lemenkov@gmail.com>
3f8d36
Date: Tue, 2 Feb 2016 17:19:19 +0300
3f8d36
Subject: [PATCH] Make slaves wait timeout configurable instead of hardcoded
3f8d36
 15000
3f8d36
3f8d36
This slightly improves rabbitmq/rabbitmq-server#584
3f8d36
3f8d36
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
3f8d36
3f8d36
diff --git a/src/rabbit_mirror_queue_master.erl b/src/rabbit_mirror_queue_master.erl
021856
index 057a4fa..e7afe88 100644
3f8d36
--- a/src/rabbit_mirror_queue_master.erl
3f8d36
+++ b/src/rabbit_mirror_queue_master.erl
021856
@@ -43,7 +43,8 @@
3f8d36
                  backing_queue_state,
3f8d36
                  seen_status,
3f8d36
                  confirmed,
3f8d36
-                 known_senders
3f8d36
+                 known_senders,
3f8d36
+                 wait_timeout
3f8d36
                }).
3f8d36
 
3f8d36
 -ifdef(use_specs).
021856
@@ -130,7 +131,15 @@ init_with_existing_bq(Q = #amqqueue{name = QName}, BQ, BQS) ->
3f8d36
              backing_queue_state = BQS,
3f8d36
              seen_status         = dict:new(),
3f8d36
              confirmed           = [],
3f8d36
-             known_senders       = sets:new() }.
3f8d36
+             known_senders       = sets:new(),
3f8d36
+             wait_timeout        = get_slave_wait_timeout() }.
3f8d36
+
3f8d36
+get_slave_wait_timeout() ->
3f8d36
+    case application:get_env(rabbit, slave_wait_timeout) of
3f8d36
+	    {ok, T}   -> T;
3f8d36
+	    undefined -> 15000
3f8d36
+    end.
3f8d36
+
3f8d36
 
3f8d36
 stop_mirroring(State = #state { coordinator         = CPid,
3f8d36
                                 backing_queue       = BQ,
021856
@@ -203,7 +212,7 @@ delete_and_terminate(Reason, State = #state { backing_queue       = BQ,
3f8d36
     stop_all_slaves(Reason, State),
3f8d36
     State#state{backing_queue_state = BQ:delete_and_terminate(Reason, BQS)}.
3f8d36
 
3f8d36
-stop_all_slaves(Reason, #state{name = QName, gm = GM}) ->
3f8d36
+stop_all_slaves(Reason, #state{name = QName, gm = GM, wait_timeout = WT}) ->
3f8d36
     {ok, #amqqueue{slave_pids = SPids}} = rabbit_amqqueue:lookup(QName),
3f8d36
     PidsMRefs = [{Pid, erlang:monitor(process, Pid)} || Pid <- [GM | SPids]],
3f8d36
     ok = gm:broadcast(GM, {delete_and_terminate, Reason}),
021856
@@ -215,7 +224,7 @@ stop_all_slaves(Reason, #state{name = QName, gm = GM}) ->
3f8d36
     [receive
3f8d36
          {'DOWN', MRef, process, _Pid, _Info} ->
3f8d36
              ok
3f8d36
-     after 15000 ->
3f8d36
+     after WT ->
3f8d36
              rabbit_mirror_queue_misc:log_warning(
3f8d36
                QName, "Missing 'DOWN' message from ~p in node ~p~n",
3f8d36
                [Pid, node(Pid)]),