summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@rabbitmq.com>2010-08-18 06:27:12 +0100
committerMatthias Radestock <matthias@rabbitmq.com>2010-08-18 06:27:12 +0100
commit29a4762324299261b0764aa1e83f6401419fa50d (patch)
tree99d2cdad77563d6d895ebf01d8cf0702e7556237 /src
parent847144a104561c58106125959cf7546c72e6e686 (diff)
downloadrabbitmq-server-git-29a4762324299261b0764aa1e83f6401419fa50d.tar.gz
small simplifying refactor
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_heartbeat.erl28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/rabbit_heartbeat.erl b/src/rabbit_heartbeat.erl
index 7c10d48a9f..ab50c28ca5 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}) ->