@@ -39,7 +39,7 @@ use libp2p_swarm::{
39
39
use smallvec:: SmallVec ;
40
40
use std:: {
41
41
collections:: VecDeque ,
42
- fmt, io ,
42
+ fmt,
43
43
sync:: {
44
44
atomic:: { AtomicU64 , Ordering } ,
45
45
Arc ,
71
71
substream_timeout : Duration ,
72
72
/// The current connection keep-alive.
73
73
keep_alive : KeepAlive ,
74
- /// A pending fatal error that results in the connection being closed.
75
- pending_error : Option < ConnectionHandlerUpgrErr < io:: Error > > ,
76
74
/// Queue of events to emit in `poll()`.
77
75
pending_events : VecDeque < Event < TCodec > > ,
78
76
/// Outbound upgrades waiting to be emitted as an `OutboundSubstreamRequest`.
@@ -113,7 +111,6 @@ where
113
111
outbound : VecDeque :: new ( ) ,
114
112
inbound : FuturesUnordered :: new ( ) ,
115
113
pending_events : VecDeque :: new ( ) ,
116
- pending_error : None ,
117
114
inbound_request_id,
118
115
}
119
116
}
@@ -156,40 +153,22 @@ where
156
153
// the remote peer does not support the requested protocol(s).
157
154
self . pending_events
158
155
. push_back ( Event :: OutboundUnsupportedProtocols ( info) ) ;
156
+ log:: debug!( "outbound stream {info} failed: Failed negotiation" ) ;
159
157
}
160
- _ => {
161
- // Anything else is considered a fatal error or misbehaviour of
162
- // the remote peer and results in closing the connection.
163
- self . pending_error = Some ( error) ;
158
+ ConnectionHandlerUpgrErr :: Upgrade ( UpgradeError :: Apply ( e) ) => {
159
+ log:: debug!( "outbound stream {info} failed: {e}" ) ;
164
160
}
161
+ _ => { }
165
162
}
166
163
}
167
164
fn on_listen_upgrade_error (
168
165
& mut self ,
169
- ListenUpgradeError { info , error } : ListenUpgradeError <
166
+ ListenUpgradeError { error , info } : ListenUpgradeError <
170
167
<Self as ConnectionHandler >:: InboundOpenInfo ,
171
168
<Self as ConnectionHandler >:: InboundProtocol ,
172
169
> ,
173
170
) {
174
- match error {
175
- ConnectionHandlerUpgrErr :: Timeout => {
176
- self . pending_events . push_back ( Event :: InboundTimeout ( info) )
177
- }
178
- ConnectionHandlerUpgrErr :: Upgrade ( UpgradeError :: Select ( NegotiationError :: Failed ) ) => {
179
- // The local peer merely doesn't support the protocol(s) requested.
180
- // This is no reason to close the connection, which may
181
- // successfully communicate with other protocols already.
182
- // An event is reported to permit user code to react to the fact that
183
- // the local peer does not support the requested protocol(s).
184
- self . pending_events
185
- . push_back ( Event :: InboundUnsupportedProtocols ( info) ) ;
186
- }
187
- _ => {
188
- // Anything else is considered a fatal error or misbehaviour of
189
- // the remote peer and results in closing the connection.
190
- self . pending_error = Some ( error) ;
191
- }
192
- }
171
+ log:: debug!( "inbound stream {info} failed: {error}" ) ;
193
172
}
194
173
}
195
174
@@ -284,7 +263,7 @@ where
284
263
{
285
264
type InEvent = RequestProtocol < TCodec > ;
286
265
type OutEvent = Event < TCodec > ;
287
- type Error = ConnectionHandlerUpgrErr < io :: Error > ;
266
+ type Error = void :: Void ;
288
267
type InboundProtocol = ResponseProtocol < TCodec > ;
289
268
type OutboundProtocol = RequestProtocol < TCodec > ;
290
269
type OutboundOpenInfo = RequestId ;
@@ -338,12 +317,6 @@ where
338
317
cx : & mut Context < ' _ > ,
339
318
) -> Poll < ConnectionHandlerEvent < RequestProtocol < TCodec > , RequestId , Self :: OutEvent , Self :: Error > >
340
319
{
341
- // Check for a pending (fatal) error.
342
- if let Some ( err) = self . pending_error . take ( ) {
343
- // The handler will not be polled again by the `Swarm`.
344
- return Poll :: Ready ( ConnectionHandlerEvent :: Close ( err) ) ;
345
- }
346
-
347
320
// Drain pending events.
348
321
if let Some ( event) = self . pending_events . pop_front ( ) {
349
322
return Poll :: Ready ( ConnectionHandlerEvent :: Custom ( event) ) ;
0 commit comments