diff options
author | Jean-Sebastien Pedron <jean-sebastien@rabbitmq.com> | 2014-11-27 13:59:05 +0100 |
---|---|---|
committer | Jean-Sebastien Pedron <jean-sebastien@rabbitmq.com> | 2014-11-27 13:59:05 +0100 |
commit | ef0661b9d2605daa748c20d289c130fa305e52ff (patch) | |
tree | c94f1207faa495c33276ca2d8eb5a59ea05a0057 | |
parent | 6c026c7445f76b0a7a20cd4d0af21298f20fc930 (diff) | |
download | rabbitmq-server-ef0661b9d2605daa748c20d289c130fa305e52ff.tar.gz |
Don't log any warning if a TCP connection is closed immediately after open
This happens with load balancers TCP healthcheck for instance.
-rw-r--r-- | src/rabbit_reader.erl | 16 |
1 files 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}}) -> |