File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 11//! Connection listener. Handles all client connections.
22
3+ use std:: io:: ErrorKind ;
34use std:: net:: SocketAddr ;
45use std:: sync:: Arc ;
56
67use crate :: backend:: databases:: { databases, reload, shutdown} ;
78use crate :: config:: config;
89use crate :: net:: messages:: BackendKeyData ;
910use crate :: net:: messages:: { hello:: SslReply , Startup } ;
10- use crate :: net:: tls:: acceptor;
11+ use crate :: net:: { self , tls:: acceptor} ;
1112use crate :: net:: { tweak, Stream } ;
1213use crate :: sighup:: Sighup ;
1314use tokio:: net:: { TcpListener , TcpStream } ;
@@ -140,7 +141,19 @@ impl Listener {
140141 let tls = acceptor ( ) ;
141142
142143 loop {
143- let startup = Startup :: from_stream ( & mut stream) . await ?;
144+ let startup = match Startup :: from_stream ( & mut stream) . await {
145+ Ok ( startup) => startup,
146+ Err ( net:: Error :: Io ( io_err) ) => {
147+ // Load balancers like AWS ELB use TCP to health check
148+ // targets and abruptly disconnect.
149+ if io_err. kind ( ) == ErrorKind :: ConnectionReset {
150+ return Ok ( ( ) ) ;
151+ } else {
152+ return Err ( net:: Error :: Io ( io_err) . into ( ) ) ;
153+ }
154+ }
155+ Err ( err) => return Err ( err. into ( ) ) ,
156+ } ;
144157
145158 match startup {
146159 Startup :: Ssl => {
You can’t perform that action at this time.
0 commit comments