diff options
| author | Michael Klishin <mklishin@pivotal.io> | 2015-07-07 22:12:54 +0300 |
|---|---|---|
| committer | Michael Klishin <mklishin@pivotal.io> | 2015-07-07 22:12:54 +0300 |
| commit | 632845bea39bce9a14ac78b8c382c060c4966cd7 (patch) | |
| tree | 41c481866dd53ba03d192a5257843956138bfbd1 | |
| parent | 5c3c0e6f38792ca37289888ce39996e6baf4d846 (diff) | |
| parent | 516f0cd84464b89beacdc0d3e53ab5cf4c0b3560 (diff) | |
| download | rabbitmq-server-git-632845bea39bce9a14ac78b8c382c060c4966cd7.tar.gz | |
Merge branch 'rabbitmq-server-159' of https://github.com/hairyhum/rabbitmq-server into hairyhum-rabbitmq-server-159
| -rw-r--r-- | src/rabbit_reader.erl | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/rabbit_reader.erl b/src/rabbit_reader.erl index 6a9eafd9fc..d296c41344 100644 --- a/src/rabbit_reader.erl +++ b/src/rabbit_reader.erl @@ -273,12 +273,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 @@ -293,6 +289,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) @@ -433,9 +445,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), |
