33
33
while let Some ( item) = incoming. next( ) . await {
34
34
yield match item {
35
35
Ok ( _) => item. map( ServerIo :: new_io) ?,
36
- Err ( e) => match handle_accept_error ( e) {
36
+ Err ( e) => match handle_tcp_accept_error ( e) {
37
37
ControlFlow :: Continue ( ( ) ) => continue ,
38
38
ControlFlow :: Break ( e) => Err ( e) ?,
39
39
}
@@ -74,11 +74,16 @@ where
74
74
yield io;
75
75
}
76
76
77
- SelectOutput :: Err ( e) => match handle_accept_error ( e) {
77
+ SelectOutput :: TcpErr ( e) => match handle_tcp_accept_error ( e) {
78
78
ControlFlow :: Continue ( ( ) ) => continue ,
79
79
ControlFlow :: Break ( e) => Err ( e) ?,
80
80
}
81
81
82
+ SelectOutput :: TlsErr ( e) => {
83
+ tracing:: debug!( error = %e, "tls accept error" ) ;
84
+ continue ;
85
+ }
86
+
82
87
SelectOutput :: Done => {
83
88
break ;
84
89
}
87
92
}
88
93
}
89
94
90
- fn handle_accept_error ( e : impl Into < crate :: Error > ) -> ControlFlow < crate :: Error > {
95
+ fn handle_tcp_accept_error ( e : impl Into < crate :: Error > ) -> ControlFlow < crate :: Error > {
91
96
let e = e. into ( ) ;
92
97
tracing:: debug!( error = %e, "accept loop error" ) ;
93
98
if let Some ( e) = e. downcast_ref :: < io:: Error > ( ) {
@@ -97,8 +102,6 @@ fn handle_accept_error(e: impl Into<crate::Error>) -> ControlFlow<crate::Error>
97
102
| io:: ErrorKind :: ConnectionReset
98
103
| io:: ErrorKind :: BrokenPipe
99
104
| io:: ErrorKind :: Interrupted
100
- | io:: ErrorKind :: InvalidData // Raised if TLS handshake failed
101
- | io:: ErrorKind :: UnexpectedEof // Raised if TLS handshake failed
102
105
| io:: ErrorKind :: WouldBlock
103
106
| io:: ErrorKind :: TimedOut
104
107
) {
@@ -121,7 +124,7 @@ where
121
124
return match incoming. try_next ( ) . await {
122
125
Ok ( Some ( stream) ) => SelectOutput :: Incoming ( stream) ,
123
126
Ok ( None ) => SelectOutput :: Done ,
124
- Err ( e) => SelectOutput :: Err ( e. into ( ) ) ,
127
+ Err ( e) => SelectOutput :: TcpErr ( e. into ( ) ) ,
125
128
} ;
126
129
}
127
130
@@ -130,15 +133,15 @@ where
130
133
match stream {
131
134
Ok ( Some ( stream) ) => SelectOutput :: Incoming ( stream) ,
132
135
Ok ( None ) => SelectOutput :: Done ,
133
- Err ( e) => SelectOutput :: Err ( e. into( ) ) ,
136
+ Err ( e) => SelectOutput :: TcpErr ( e. into( ) ) ,
134
137
}
135
138
}
136
139
137
140
accept = tasks. join_next( ) => {
138
141
match accept. expect( "JoinSet should never end" ) {
139
142
Ok ( Ok ( io) ) => SelectOutput :: Io ( io) ,
140
- Ok ( Err ( e) ) => SelectOutput :: Err ( e) ,
141
- Err ( e) => SelectOutput :: Err ( e. into( ) ) ,
143
+ Ok ( Err ( e) ) => SelectOutput :: TlsErr ( e) ,
144
+ Err ( e) => SelectOutput :: TlsErr ( e. into( ) ) ,
142
145
}
143
146
}
144
147
}
@@ -148,7 +151,8 @@ where
148
151
enum SelectOutput < A > {
149
152
Incoming ( A ) ,
150
153
Io ( ServerIo < A > ) ,
151
- Err ( crate :: Error ) ,
154
+ TcpErr ( crate :: Error ) ,
155
+ TlsErr ( crate :: Error ) ,
152
156
Done ,
153
157
}
154
158
0 commit comments