@@ -270,13 +270,20 @@ where C: Connect + Sync + 'static,
270
270
. http2_only ( pool_key. 1 == Ver :: Http2 )
271
271
. handshake ( io)
272
272
. and_then ( move |( tx, conn) | {
273
- executor. execute ( conn. map_err ( |e| {
273
+ let bg = executor. execute ( conn. map_err ( |e| {
274
274
debug ! ( "client connection error: {}" , e)
275
275
} ) ) ;
276
276
277
+ // This task is critical, so an execute error
278
+ // should be returned.
279
+ if let Err ( err) = bg {
280
+ warn ! ( "error spawning critical client task: {}" , err) ;
281
+ return Either :: A ( future:: err ( err) ) ;
282
+ }
283
+
277
284
// Wait for 'conn' to ready up before we
278
285
// declare this tx as usable
279
- tx. when_ready ( )
286
+ Either :: B ( tx. when_ready ( ) )
280
287
} )
281
288
. map ( move |tx| {
282
289
pool. pooled ( connecting, PoolClient {
@@ -373,26 +380,32 @@ where C: Connect + Sync + 'static,
373
380
} else if !res. body ( ) . is_end_stream ( ) {
374
381
let ( delayed_tx, delayed_rx) = oneshot:: channel ( ) ;
375
382
res. body_mut ( ) . delayed_eof ( delayed_rx) ;
376
- executor. execute (
377
- future:: poll_fn ( move || {
378
- pooled. poll_ready ( )
379
- } )
383
+ let on_idle = future:: poll_fn ( move || {
384
+ pooled. poll_ready ( )
385
+ } )
380
386
. then ( move |_| {
381
387
// At this point, `pooled` is dropped, and had a chance
382
388
// to insert into the pool (if conn was idle)
383
389
drop ( delayed_tx) ;
384
390
Ok ( ( ) )
385
- } )
386
- ) ;
391
+ } ) ;
392
+
393
+ if let Err ( err) = executor. execute ( on_idle) {
394
+ // This task isn't critical, so just log and ignore.
395
+ warn ! ( "error spawning task to insert idle connection: {}" , err) ;
396
+ }
387
397
} else {
388
398
// There's no body to delay, but the connection isn't
389
399
// ready yet. Only re-insert when it's ready
390
- executor. execute (
391
- future:: poll_fn ( move || {
392
- pooled. poll_ready ( )
393
- } )
394
- . then ( |_| Ok ( ( ) ) )
395
- ) ;
400
+ let on_idle = future:: poll_fn ( move || {
401
+ pooled. poll_ready ( )
402
+ } )
403
+ . then ( |_| Ok ( ( ) ) ) ;
404
+
405
+ if let Err ( err) = executor. execute ( on_idle) {
406
+ // This task isn't critical, so just log and ignore.
407
+ warn ! ( "error spawning task to insert idle connection: {}" , err) ;
408
+ }
396
409
}
397
410
Ok ( res)
398
411
} ) ;
0 commit comments