@@ -1831,7 +1831,7 @@ impl Container {
18311831 already_cancelled = true ;
18321832
18331833 let msg = CoordinatorMessage :: Kill ;
1834- trace!( "processing { msg:?} ") ;
1834+ trace!( msg_name = msg. as_ref ( ) , "processing ") ;
18351835 to_worker_tx. send( msg) . await . context( KillSnafu ) ?;
18361836 } ,
18371837
@@ -1847,12 +1847,12 @@ impl Container {
18471847 }
18481848 } ;
18491849
1850- trace!( "processing { msg:?} ") ;
1850+ trace!( msg_name = msg. as_ref ( ) , "processing ") ;
18511851 to_worker_tx. send( msg) . await . context( StdinSnafu ) ?;
18521852 } ,
18531853
18541854 Some ( container_msg) = from_worker_rx. recv( ) => {
1855- trace!( "processing { container_msg:?} ") ;
1855+ trace!( msg_name = container_msg. as_ref ( ) , "processing ") ;
18561856
18571857 match container_msg {
18581858 WorkerMessage :: ExecuteCommand ( resp) => {
@@ -2358,48 +2358,63 @@ impl Commander {
23582358 gc_interval. set_missed_tick_behavior ( MissedTickBehavior :: Delay ) ;
23592359
23602360 loop {
2361- select ! {
2362- command = command_rx. recv( ) => {
2363- let Some ( ( ack_tx, command) ) = command else { break } ;
2361+ enum Event {
2362+ Command ( Option < ( oneshot:: Sender < ( ) > , DemultiplexCommand ) > ) ,
23642363
2364+ FromWorker ( Option < Multiplexed < WorkerMessage > > ) ,
2365+
2366+ // Find any channels where the receivers have been
2367+ // dropped and clear out the sending halves.
2368+ Gc ,
2369+ }
2370+ use Event :: * ;
2371+
2372+ let event = select ! {
2373+ command = command_rx. recv( ) => Command ( command) ,
2374+
2375+ msg = from_worker_rx. recv( ) => FromWorker ( msg) ,
2376+
2377+ _ = gc_interval. tick( ) => Gc ,
2378+ } ;
2379+
2380+ match event {
2381+ Command ( None ) => break ,
2382+ Command ( Some ( ( ack_tx, command) ) ) => {
23652383 match command {
23662384 DemultiplexCommand :: Listen ( job_id, waiter) => {
2367- trace!( "adding listener for {job_id:?} " ) ;
2385+ trace ! ( job_id , "adding listener (many) " ) ;
23682386 let old = waiting. insert ( job_id, waiter) ;
23692387 ensure ! ( old. is_none( ) , DuplicateDemultiplexerClientSnafu { job_id } ) ;
23702388 }
23712389
23722390 DemultiplexCommand :: ListenOnce ( job_id, waiter) => {
2373- trace!( "adding listener for {job_id:?} " ) ;
2391+ trace ! ( job_id , "adding listener (once) " ) ;
23742392 let old = waiting_once. insert ( job_id, waiter) ;
23752393 ensure ! ( old. is_none( ) , DuplicateDemultiplexerClientSnafu { job_id } ) ;
23762394 }
23772395 }
23782396
23792397 ack_tx. send ( ( ) ) . ok ( /* Don't care about it */ ) ;
2380- } ,
2381-
2382- msg = from_worker_rx. recv( ) => {
2383- let Some ( Multiplexed ( job_id, msg) ) = msg else { break } ;
2398+ }
23842399
2400+ FromWorker ( None ) => break ,
2401+ FromWorker ( Some ( Multiplexed ( job_id, msg) ) ) => {
23852402 if let Some ( waiter) = waiting_once. remove ( & job_id) {
2386- trace!( "notifying listener for {job_id:?} " ) ;
2403+ trace ! ( job_id , "notifying listener (once) " ) ;
23872404 waiter. send ( msg) . ok ( /* Don't care about it */ ) ;
23882405 continue ;
23892406 }
23902407
23912408 if let Some ( waiter) = waiting. get ( & job_id) {
2392- trace!( "notifying listener for {job_id:?} " ) ;
2409+ trace ! ( job_id , "notifying listener (many) " ) ;
23932410 waiter. send ( msg) . await . ok ( /* Don't care about it */ ) ;
23942411 continue ;
23952412 }
23962413
2397- warn!( "no listener for {job_id:?} " ) ;
2414+ warn ! ( job_id , "no listener to notify " ) ;
23982415 }
23992416
2400- // Find any channels where the receivers have been
2401- // dropped and clear out the sending halves.
2402- _ = gc_interval. tick( ) => {
2417+ Gc => {
24032418 waiting = mem:: take ( & mut waiting)
24042419 . into_iter ( )
24052420 . filter ( |( _job_id, tx) | !tx. is_closed ( ) )
0 commit comments