diff options
author | Rob Harrop <rob@rabbitmq.com> | 2010-11-10 11:47:51 +0000 |
---|---|---|
committer | Rob Harrop <rob@rabbitmq.com> | 2010-11-10 11:47:51 +0000 |
commit | ef25dbf2c2b037d7b6c213213c88c7ffec70a291 (patch) | |
tree | 5204b3232354c3683e0150a2662ad1e1771960ee /src/rabbit_connection_sup.erl | |
parent | 59b4142070bf526299c400aef84370d022eb52b0 (diff) | |
download | rabbitmq-server-ef25dbf2c2b037d7b6c213213c88c7ffec70a291.tar.gz |
Refactored rabbit_heartbeat to provide start_heartbeat_fun
Diffstat (limited to 'src/rabbit_connection_sup.erl')
-rw-r--r-- | src/rabbit_connection_sup.erl | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/src/rabbit_connection_sup.erl b/src/rabbit_connection_sup.erl index b3821d3b..bb5ed916 100644 --- a/src/rabbit_connection_sup.erl +++ b/src/rabbit_connection_sup.erl @@ -79,21 +79,13 @@ init([]) -> {ok, {{one_for_all, 0, 1}, []}}. start_heartbeat_fun(SupPid) -> - fun (_Sock, 0) -> - none; - (Sock, TimeoutSec) -> - Parent = self(), - {ok, Sender} = - supervisor2:start_child( - SupPid, {heartbeat_sender, - {rabbit_heartbeat, start_heartbeat_sender, - [Parent, Sock, TimeoutSec]}, - transient, ?MAX_WAIT, worker, [rabbit_heartbeat]}), - {ok, Receiver} = - supervisor2:start_child( - SupPid, {heartbeat_receiver, - {rabbit_heartbeat, start_heartbeat_receiver, - [Parent, Sock, TimeoutSec]}, - transient, ?MAX_WAIT, worker, [rabbit_heartbeat]}), - {Sender, Receiver} - end. + SendFun = fun(Sock) -> + Frame = rabbit_binary_generator:build_heartbeat_frame(), + catch rabbit_net:send(Sock, Frame) + end, + + Parent = self(), + TimeoutFun = fun() -> + Parent ! timeout + end, + rabbit_heartbeat:start_heartbeat_fun(SupPid, SendFun, TimeoutFun). |