From ef0661b9d2605daa748c20d289c130fa305e52ff Mon Sep 17 00:00:00 2001 From: Jean-Sebastien Pedron Date: Thu, 27 Nov 2014 13:59:05 +0100 Subject: Don't log any warning if a TCP connection is closed immediately after open This happens with load balancers TCP healthcheck for instance. --- src/rabbit_reader.erl | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/rabbit_reader.erl b/src/rabbit_reader.erl index ca73006a..e96a911c 100644 --- a/src/rabbit_reader.erl +++ b/src/rabbit_reader.erl @@ -334,10 +334,18 @@ mainloop(Deb, Buf, BufLen, State = #v1{sock = Sock}) -> end end. -stop(closed, State) -> maybe_emit_stats(State), - throw(connection_closed_abruptly); -stop(Reason, State) -> maybe_emit_stats(State), - throw({inet_error, Reason}). +stop(closed, #v1{connection_state = pre_init} = State) -> + %% The connection was closed before any packet was received. It's + %% probably a load-balancer healthcheck: don't consider this a + %% failure. + maybe_emit_stats(State), + ok; +stop(closed, State) -> + maybe_emit_stats(State), + throw({connection_closed_abruptly, State}); +stop(Reason, State) -> + maybe_emit_stats(State), + throw({inet_error, Reason}). handle_other({conserve_resources, Source, Conserve}, State = #v1{throttle = Throttle = #throttle{alarmed_by = CR}}) -> -- cgit v1.2.1