From 0079936dae2c931670b857586ee69e94060df03d Mon Sep 17 00:00:00 2001 From: Simon MacMullen Date: Thu, 23 Aug 2012 16:19:35 +0100 Subject: Try to be a bit more defensive before looping. --- src/rabbit_amqqueue.erl | 13 +++++++++++-- 1 file 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() -- cgit v1.2.1