summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Klishin <mklishin@pivotal.io>2015-07-07 23:00:48 +0300
committerMichael Klishin <mklishin@pivotal.io>2015-07-07 23:00:48 +0300
commitba17cacc5c22260f7ca0e2dafb18b6af69fcc9d9 (patch)
tree28ce4baf3705bddde31988c33f7166dabac64ed2 /src
parentbd3cd13db7febaad658d6738b8074442f9662375 (diff)
parent632845bea39bce9a14ac78b8c382c060c4966cd7 (diff)
downloadrabbitmq-server-git-ba17cacc5c22260f7ca0e2dafb18b6af69fcc9d9.tar.gz
Merge branch 'stable'
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_reader.erl29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/rabbit_reader.erl b/src/rabbit_reader.erl
index 757b467104..5781e9f0d4 100644
--- a/src/rabbit_reader.erl
+++ b/src/rabbit_reader.erl
@@ -379,12 +379,8 @@ start_connection(Parent, HelperSup, Deb, Sock, SockTransform) ->
handshake, 8)]}),
log(info, "closing AMQP connection ~p (~s)~n", [self(), Name])
catch
- Ex -> log(case Ex of
- connection_closed_with_no_data_received -> debug;
- connection_closed_abruptly -> warning;
- _ -> error
- end, "closing AMQP connection ~p (~s):~n~p~n",
- [self(), Name, Ex])
+ Ex ->
+ log_connection_exception(Name, Ex)
after
%% We don't call gen_tcp:close/1 here since it waits for
%% pending output to be sent, which results in unnecessary
@@ -399,6 +395,22 @@ start_connection(Parent, HelperSup, Deb, Sock, SockTransform) ->
end,
done.
+log_connection_exception(Name, Ex) ->
+ Severity = case Ex of
+ connection_closed_with_no_data_received -> debug;
+ connection_closed_abruptly -> warning;
+ _ -> error
+ end,
+ log_connection_exception(Severity, Name, Ex).
+
+log_connection_exception(Severity, Name, {heartbeat_timeout, TimeoutSec}) ->
+ %% Long line to avoid extra spaces and line breaks in log
+ log(Severity, "closing AMQP connection ~p (~s):~nMissed heartbeats from client, timeout: ~ps~n",
+ [self(), Name, TimeoutSec]);
+log_connection_exception(Severity, Name, Ex) ->
+ log(Severity, "closing AMQP connection ~p (~s):~n~p~n",
+ [self(), Name, Ex]).
+
run({M, F, A}) ->
try apply(M, F, A)
catch {become, MFA} -> run(MFA)
@@ -539,9 +551,10 @@ handle_other(handshake_timeout, State) ->
throw({handshake_timeout, State#v1.callback});
handle_other(heartbeat_timeout, State = #v1{connection_state = closed}) ->
State;
-handle_other(heartbeat_timeout, State = #v1{connection_state = S}) ->
+handle_other(heartbeat_timeout,
+ State = #v1{connection = #connection{timeout_sec = T}}) ->
maybe_emit_stats(State),
- throw({heartbeat_timeout, S});
+ throw({heartbeat_timeout, T});
handle_other({'$gen_call', From, {shutdown, Explanation}}, State) ->
{ForceTermination, NewState} = terminate(Explanation, State),
gen_server:reply(From, ok),