summaryrefslogtreecommitdiff
path: root/src/rabbit_heartbeat.erl
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@rabbitmq.com>2010-07-06 15:13:28 +0100
committerMatthew Sackman <matthew@rabbitmq.com>2010-07-06 15:13:28 +0100
commit4c5794188c5e046ad6141573b52a323ee3aca989 (patch)
tree185dfb263954f4680bcd77b472eeac49086d87c5 /src/rabbit_heartbeat.erl
parent602dd321af9badc83d930785d6dc5d6e9bbbe518 (diff)
downloadrabbitmq-server-4c5794188c5e046ad6141573b52a323ee3aca989.tar.gz
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.
Diffstat (limited to 'src/rabbit_heartbeat.erl')
-rw-r--r--src/rabbit_heartbeat.erl12
1 files changed, 4 insertions, 8 deletions
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