@@ -1264,7 +1264,7 @@ struct CtlClient {
12641264 events : bool ,
12651265 seen_events : BTreeSet < ( String , String ) > ,
12661266 spawn_wait : Option < u64 > ,
1267- spawn_retry : Option < ( String , Vec < String > ) > ,
1267+ spawn_retry : Option < ( String , Vec < String > , bool ) > ,
12681268}
12691269
12701270fn accept_ctl_hello ( mut reader : BufReader < UnixStream > , pin : u32 , clients : & mut Vec < CtlClient > ) {
@@ -1323,8 +1323,8 @@ fn poll_ctl_clients(clients: &mut Vec<CtlClient>, node: &mut SharedLayoutNode) -
13231323
13241324fn poll_one_ctl ( client : & mut CtlClient , node : & mut SharedLayoutNode ) -> io:: Result < bool > {
13251325 let mut did_work = false ;
1326- if let Some ( ( machine, command) ) = client. spawn_retry . clone ( ) {
1327- match dispatch_ctl_spawn ( node, client, machine, command) {
1326+ if let Some ( ( machine, command, new ) ) = client. spawn_retry . clone ( ) {
1327+ match dispatch_ctl_spawn ( node, client, machine, command, new ) {
13281328 Ok ( true ) => {
13291329 client. spawn_retry = None ;
13301330 did_work = true ;
@@ -1342,13 +1342,9 @@ fn poll_one_ctl(client: &mut CtlClient, node: &mut SharedLayoutNode) -> io::Resu
13421342 {
13431343 client. spawn_wait = None ;
13441344 match result {
1345- Ok ( pane_id) => ctl:: write_json (
1346- client. reader . get_mut ( ) ,
1347- & CtlToClient :: Spawned {
1348- pane_id,
1349- reused : false ,
1350- } ,
1351- ) ?,
1345+ Ok ( pane_id) => {
1346+ ctl:: write_json ( client. reader . get_mut ( ) , & ctl_spawned ( node, pane_id, false ) ) ?
1347+ }
13521348 Err ( message) => {
13531349 ctl:: write_json ( client. reader . get_mut ( ) , & CtlToClient :: Error { message } ) ?
13541350 }
@@ -1386,8 +1382,12 @@ fn poll_one_ctl(client: &mut CtlClient, node: &mut SharedLayoutNode) -> io::Resu
13861382 ) ?;
13871383 did_work = true ;
13881384 }
1389- Ok ( Some ( CtlFromClient :: Spawn { machine, command } ) ) => {
1390- match dispatch_ctl_spawn ( node, client, machine, command) {
1385+ Ok ( Some ( CtlFromClient :: Spawn {
1386+ machine,
1387+ command,
1388+ new,
1389+ } ) ) => {
1390+ match dispatch_ctl_spawn ( node, client, machine, command, new) {
13911391 Ok ( _) => { }
13921392 Err ( message) => {
13931393 ctl:: write_json ( client. reader . get_mut ( ) , & CtlToClient :: Error { message } ) ?
@@ -1432,7 +1432,9 @@ fn poll_one_ctl(client: &mut CtlClient, node: &mut SharedLayoutNode) -> io::Resu
14321432 Err ( error)
14331433 if matches ! (
14341434 error. kind( ) ,
1435- io:: ErrorKind :: ConnectionReset | io:: ErrorKind :: BrokenPipe
1435+ io:: ErrorKind :: ConnectionReset
1436+ | io:: ErrorKind :: BrokenPipe
1437+ | io:: ErrorKind :: UnexpectedEof
14361438 ) =>
14371439 {
14381440 return Err ( error) ;
@@ -1447,35 +1449,26 @@ fn dispatch_ctl_spawn(
14471449 client : & mut CtlClient ,
14481450 machine : String ,
14491451 command : Vec < String > ,
1452+ new : bool ,
14501453) -> Result < bool , String > {
1451- match node. runtime . ctl_try_spawn ( & machine, command. clone ( ) ) {
1454+ match node. runtime . ctl_try_spawn ( & machine, command. clone ( ) , new ) {
14521455 Ok ( crate :: ctl:: CtlSpawn :: Reused ( pane_id) ) => {
1453- ctl:: write_json (
1454- client. reader . get_mut ( ) ,
1455- & CtlToClient :: Spawned {
1456- pane_id,
1457- reused : true ,
1458- } ,
1459- )
1460- . map_err ( |error| error. to_string ( ) ) ?;
1456+ ctl:: write_json ( client. reader . get_mut ( ) , & ctl_spawned ( node, pane_id, true ) )
1457+ . map_err ( |error| error. to_string ( ) ) ?;
14611458 Ok ( true )
14621459 }
14631460 Ok ( crate :: ctl:: CtlSpawn :: Busy ) => {
1464- client. spawn_retry = Some ( ( machine, command) ) ;
1461+ client. spawn_retry = Some ( ( machine, command, new ) ) ;
14651462 Ok ( false )
14661463 }
14671464 Ok ( crate :: ctl:: CtlSpawn :: Started ( request_id) ) => {
14681465 let _ = node. drain ( ) ;
14691466 if let Some ( result) = node. runtime . ctl_take_result ( request_id) {
14701467 match result {
1471- Ok ( pane_id) => ctl:: write_json (
1472- client. reader . get_mut ( ) ,
1473- & CtlToClient :: Spawned {
1474- pane_id,
1475- reused : false ,
1476- } ,
1477- )
1478- . map_err ( |error| error. to_string ( ) ) ?,
1468+ Ok ( pane_id) => {
1469+ ctl:: write_json ( client. reader . get_mut ( ) , & ctl_spawned ( node, pane_id, false ) )
1470+ . map_err ( |error| error. to_string ( ) ) ?
1471+ }
14791472 Err ( message) => {
14801473 return Err ( message) ;
14811474 }
@@ -1489,6 +1482,14 @@ fn dispatch_ctl_spawn(
14891482 }
14901483}
14911484
1485+ fn ctl_spawned ( node : & mut SharedLayoutNode , pane_id : u64 , reused : bool ) -> CtlToClient {
1486+ CtlToClient :: Spawned {
1487+ pane_id,
1488+ reused,
1489+ visible_to_guests : node. runtime . ctl_visible_to_guests ( ) ,
1490+ }
1491+ }
1492+
14921493fn publish_ctl_events ( client : & mut CtlClient , node : & mut SharedLayoutNode ) -> io:: Result < bool > {
14931494 let mut wrote = false ;
14941495 let mut seen = BTreeSet :: new ( ) ;
0 commit comments