summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2012-08-23 16:19:35 +0100
committerSimon MacMullen <simon@rabbitmq.com>2012-08-23 16:19:35 +0100
commit0079936dae2c931670b857586ee69e94060df03d (patch)
tree331ad589df93fcbd049a7ea58633b946e12aab93
parente995574d870ed729182f5ad0b195bd24d529ac81 (diff)
downloadrabbitmq-server-bug25114.tar.gz
Try to be a bit more defensive before looping.bug25114
-rw-r--r--src/rabbit_amqqueue.erl13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl
index a5f227bc..461b25eb 100644
--- a/src/rabbit_amqqueue.erl
+++ b/src/rabbit_amqqueue.erl
@@ -311,8 +311,17 @@ with(Name, F, E) ->
case lookup(Name) of
{ok, Q = #amqqueue{slave_pids = []}} ->
rabbit_misc:with_exit_handler(E, fun () -> F(Q) end);
- {ok, Q} ->
- E1 = fun () -> timer:sleep(25), with(Name, F, E) end,
+ {ok, Q = #amqqueue{pid = QPid}} ->
+ %% We check is_process_alive(QPid) in case we receive a
+ %% nodedown (for example) in F() that has nothing to do
+ %% with the QPid.
+ E1 = fun () ->
+ case rabbit_misc:is_process_alive(QPid) of
+ true -> E();
+ false -> timer:sleep(25),
+ with(Name, F, E)
+ end
+ end,
rabbit_misc:with_exit_handler(E1, fun () -> F(Q) end);
{error, not_found} ->
E()