@@ -121,13 +121,14 @@ impl Stream for AddrIncoming {
121
121
} ,
122
122
Ok ( Async :: NotReady ) => return Ok ( Async :: NotReady ) ,
123
123
Err ( e) => {
124
+ // Connection errors can be ignored directly, continue by
125
+ // accepting the next request.
126
+ if is_connection_error ( & e) {
127
+ debug ! ( "accepted connection already errored: {}" , e) ;
128
+ continue ;
129
+ }
130
+
124
131
if self . sleep_on_errors {
125
- // Connection errors can be ignored directly, continue by
126
- // accepting the next request.
127
- if is_connection_error ( & e) {
128
- debug ! ( "accepted connection already errored: {}" , e) ;
129
- continue ;
130
- }
131
132
// Sleep 1s.
132
133
let delay = Instant :: now ( ) + Duration :: from_secs ( 1 ) ;
133
134
let mut timeout = Delay :: new ( delay) ;
@@ -165,9 +166,12 @@ impl Stream for AddrIncoming {
165
166
/// The timeout is useful to handle resource exhaustion errors like ENFILE
166
167
/// and EMFILE. Otherwise, could enter into tight loop.
167
168
fn is_connection_error ( e : & io:: Error ) -> bool {
168
- e. kind ( ) == io:: ErrorKind :: ConnectionRefused ||
169
- e. kind ( ) == io:: ErrorKind :: ConnectionAborted ||
170
- e. kind ( ) == io:: ErrorKind :: ConnectionReset
169
+ match e. kind ( ) {
170
+ io:: ErrorKind :: ConnectionRefused |
171
+ io:: ErrorKind :: ConnectionAborted |
172
+ io:: ErrorKind :: ConnectionReset => true ,
173
+ _ => false ,
174
+ }
171
175
}
172
176
173
177
impl fmt:: Debug for AddrIncoming {
0 commit comments