From 4c5794188c5e046ad6141573b52a323ee3aca989 Mon Sep 17 00:00:00 2001 From: Matthew Sackman Date: Tue, 6 Jul 2010 15:13:28 +0100 Subject: The heartbeater doesn't need to signal the reader in the event of a timeout - it should just exit abnormally and rely on the supervisor to tear everything down, esp seeing as the reader previously was just throwing the timeout exception. --- src/rabbit_heartbeat.erl | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/rabbit_heartbeat.erl') diff --git a/src/rabbit_heartbeat.erl b/src/rabbit_heartbeat.erl index f4df128d..bca27dd7 100644 --- a/src/rabbit_heartbeat.erl +++ b/src/rabbit_heartbeat.erl @@ -35,12 +35,11 @@ -export([start_heartbeat/3, start_heartbeat_sender/2, - start_heartbeat_receiver/3]). + start_heartbeat_receiver/2]). start_heartbeat(_Sup, _Sock, 0) -> none; start_heartbeat(Sup, Sock, TimeoutSec) -> - Parent = self(), {ok, _Sender} = supervisor:start_child( Sup, {heartbeat_sender, @@ -49,7 +48,7 @@ start_heartbeat(Sup, Sock, TimeoutSec) -> {ok, _Receiver} = supervisor:start_child( Sup, {heartbeat_receiver, - {?MODULE, start_heartbeat_receiver, [Parent, Sock, TimeoutSec]}, + {?MODULE, start_heartbeat_receiver, [Sock, TimeoutSec]}, permanent, ?MAX_WAIT, worker, [rabbit_heartbeat]}), ok. @@ -66,17 +65,14 @@ start_heartbeat_sender(Sock, TimeoutSec) -> end) end)}. -start_heartbeat_receiver(Parent, Sock, TimeoutSec) -> +start_heartbeat_receiver(Sock, TimeoutSec) -> %% we check for incoming data every interval, and time out after %% two checks with no change. As a result we will time out between %% 2 and 3 intervals after the last data has been received. {ok, proc_lib:spawn_link( fun () -> heartbeater(Sock, TimeoutSec * 1000, recv_oct, 1, - fun () -> - Parent ! timeout, - stop - end) + fun () -> exit(timeout) end) end)}. %% Y-combinator, posted by Vladimir Sekissov to the Erlang mailing list -- cgit v1.2.1