diff options
author | Matthew Sackman <matthew@rabbitmq.com> | 2010-08-10 15:05:21 +0100 |
---|---|---|
committer | Matthew Sackman <matthew@rabbitmq.com> | 2010-08-10 15:05:21 +0100 |
commit | 6fe45dcc722c13b093c90c934a4743adbfa17d9e (patch) | |
tree | 08eb81340bcde07b7123fba946c804a78c112ee6 /src/rabbit_connection_sup.erl | |
parent | 601f79c7e42ee9755999a4bc4f54b6ec59dc4598 (diff) | |
download | rabbitmq-server-6fe45dcc722c13b093c90c934a4743adbfa17d9e.tar.gz |
Abstract the heartbeaters in the same way - the reader now has no references to supervisor(2)?:.* nor does heartbeater.
Diffstat (limited to 'src/rabbit_connection_sup.erl')
-rw-r--r-- | src/rabbit_connection_sup.erl | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/rabbit_connection_sup.erl b/src/rabbit_connection_sup.erl index aee8d987..354540c1 100644 --- a/src/rabbit_connection_sup.erl +++ b/src/rabbit_connection_sup.erl @@ -54,7 +54,8 @@ start_link() -> {ok, _ReaderPid} = supervisor2:start_child( SupPid, - {reader, {rabbit_reader, start_link, [ChannelSupSupPid, Collector]}, + {reader, {rabbit_reader, start_link, + [ChannelSupSupPid, Collector, start_heartbeat_fun(SupPid)]}, intrinsic, ?MAX_WAIT, worker, [rabbit_reader]}), {ok, SupPid}. @@ -63,3 +64,23 @@ init([]) -> reader(Pid) -> hd(supervisor2:find_child(Pid, reader)). + +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]}, + intrinsic, ?MAX_WAIT, worker, [rabbit_heartbeat]}), + {ok, Receiver} = + supervisor2:start_child( + SupPid, {heartbeat_receiver, + {rabbit_heartbeat, start_heartbeat_receiver, + [Parent, Sock, TimeoutSec]}, + intrinsic, ?MAX_WAIT, worker, [rabbit_heartbeat]}), + {Sender, Receiver} + end. |