File tree 2 files changed +7
-7
lines changed
compiler/base/orchestrator/src
2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ use snafu::prelude::*;
4
4
use std:: {
5
5
collections:: { BTreeSet , HashMap } ,
6
6
fmt, mem, ops,
7
+ pin:: pin,
7
8
process:: Stdio ,
8
9
sync:: {
9
10
atomic:: { AtomicU64 , Ordering } ,
@@ -1839,14 +1840,12 @@ impl Container {
1839
1840
1840
1841
let task = tokio:: spawn ( {
1841
1842
async move {
1842
- let mut already_cancelled = false ;
1843
+ let mut cancelled = pin ! ( token . cancelled ( ) . fuse ( ) ) ;
1843
1844
let mut stdin_open = true ;
1844
1845
1845
1846
loop {
1846
1847
select ! {
1847
- ( ) = token. cancelled( ) , if !already_cancelled => {
1848
- already_cancelled = true ;
1849
-
1848
+ ( ) = & mut cancelled => {
1850
1849
let msg = CoordinatorMessage :: Kill ;
1851
1850
trace!( msg_name = msg. as_ref( ) , "processing" ) ;
1852
1851
to_worker_tx. send( msg) . await . context( KillSnafu ) ?;
Original file line number Diff line number Diff line change 31
31
//! - [`tokio::process::ChildStderr`][]
32
32
//!
33
33
34
+ use futures:: FutureExt as _;
34
35
use snafu:: prelude:: * ;
35
36
use std:: {
36
37
collections:: HashMap ,
37
38
io,
38
39
path:: { Path , PathBuf } ,
40
+ pin:: pin,
39
41
process:: { ExitStatus , Stdio } ,
40
42
} ;
41
43
use tokio:: {
@@ -615,14 +617,13 @@ async fn process_end(
615
617
) -> Result < ExecuteCommandResponse , ProcessError > {
616
618
use process_error:: * ;
617
619
618
- let mut killed = false ;
620
+ let mut cancelled = pin ! ( token . cancelled ( ) . fuse ( ) ) ;
619
621
620
622
let status = loop {
621
623
select ! {
622
624
// The user requested that the process be killed
623
- ( ) = token . cancelled ( ) , if !killed => {
625
+ ( ) = & mut cancelled => {
624
626
child. kill( ) . await . context( KillChildSnafu ) ?;
625
- killed = true ;
626
627
} ,
627
628
628
629
// The process exited normally
You can’t perform that action at this time.
0 commit comments