diff options
author | Matthias Radestock <matthias@rabbitmq.com> | 2010-08-18 06:27:12 +0100 |
---|---|---|
committer | Matthias Radestock <matthias@rabbitmq.com> | 2010-08-18 06:27:12 +0100 |
commit | dbded325f13be936a505e25c5c1110d66b75cbd0 (patch) | |
tree | 99d2cdad77563d6d895ebf01d8cf0702e7556237 | |
parent | fd4f2d45610a3f2ce651d08a42f6a3e4a1277dca (diff) | |
download | rabbitmq-server-dbded325f13be936a505e25c5c1110d66b75cbd0.tar.gz |
small simplifying refactor
-rw-r--r-- | src/rabbit_heartbeat.erl | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/src/rabbit_heartbeat.erl b/src/rabbit_heartbeat.erl index 7c10d48a..ab50c28c 100644 --- a/src/rabbit_heartbeat.erl +++ b/src/rabbit_heartbeat.erl @@ -55,23 +55,19 @@ start_heartbeat(Sock, TimeoutSec) -> %% the 'div 2' is there so that we don't end up waiting for nearly %% 2 * TimeoutSec before sending a heartbeat in the boundary case %% where the last message was sent just after a heartbeat. - Sender = - spawn_link(fun () -> heartbeater({Sock, TimeoutSec * 1000 div 2, - send_oct, 0, - fun () -> - catch rabbit_net:send(Sock, rabbit_binary_generator:build_heartbeat_frame()), - continue - end}, Parent) end), + Sender = heartbeater({Sock, TimeoutSec * 1000 div 2, send_oct, 0, + fun () -> + catch rabbit_net:send(Sock, rabbit_binary_generator:build_heartbeat_frame()), + continue + end}, Parent), %% 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. - Receiver = - spawn_link(fun () -> heartbeater({Sock, TimeoutSec * 1000, - recv_oct, 1, - fun () -> - Parent ! timeout, - stop - end}, Parent) end), + Receiver = heartbeater({Sock, TimeoutSec * 1000, recv_oct, 1, + fun () -> + Parent ! timeout, + stop + end}, Parent), {Sender, Receiver}. pause_monitor(none) -> @@ -89,7 +85,9 @@ resume_monitor({_Sender, Receiver}) -> %%---------------------------------------------------------------------------- heartbeater(Params, Parent) -> - heartbeater(Params, erlang:monitor(process, Parent), {0, 0}). + spawn_link(fun () -> heartbeater(Params, erlang:monitor(process, Parent), + {0, 0}) + end). heartbeater({Sock, TimeoutMillisec, StatName, Threshold, Handler} = Params, MonitorRef, {StatVal, SameCount}) -> |