@@ -1842,18 +1842,33 @@ impl Container {
1842
1842
let mut stdin_open = true ;
1843
1843
1844
1844
loop {
1845
- select ! {
1846
- ( ) = & mut cancelled => {
1845
+ enum Event {
1846
+ Cancelled ,
1847
+ Stdin ( Option < String > ) ,
1848
+ FromWorker ( WorkerMessage ) ,
1849
+ }
1850
+ use Event :: * ;
1851
+
1852
+ let event = select ! {
1853
+ ( ) = & mut cancelled => Cancelled ,
1854
+
1855
+ stdin = stdin_rx. recv( ) , if stdin_open => Stdin ( stdin) ,
1856
+
1857
+ Some ( container_msg) = from_worker_rx. recv( ) => FromWorker ( container_msg) ,
1858
+
1859
+ else => return UnexpectedEndOfMessagesSnafu . fail( ) ,
1860
+ } ;
1861
+
1862
+ match event {
1863
+ Cancelled => {
1847
1864
let msg = CoordinatorMessage :: Kill ;
1848
1865
trace ! ( msg_name = msg. as_ref( ) , "processing" ) ;
1849
1866
to_worker_tx. send ( msg) . await . context ( KillSnafu ) ?;
1850
- } ,
1867
+ }
1851
1868
1852
- stdin = stdin_rx . recv ( ) , if stdin_open => {
1869
+ Stdin ( stdin ) => {
1853
1870
let msg = match stdin {
1854
- Some ( stdin) => {
1855
- CoordinatorMessage :: StdinPacket ( stdin)
1856
- }
1871
+ Some ( stdin) => CoordinatorMessage :: StdinPacket ( stdin) ,
1857
1872
1858
1873
None => {
1859
1874
stdin_open = false ;
@@ -1863,9 +1878,9 @@ impl Container {
1863
1878
1864
1879
trace ! ( msg_name = msg. as_ref( ) , "processing" ) ;
1865
1880
to_worker_tx. send ( msg) . await . context ( StdinSnafu ) ?;
1866
- } ,
1881
+ }
1867
1882
1868
- Some ( container_msg) = from_worker_rx . recv ( ) => {
1883
+ FromWorker ( container_msg) => {
1869
1884
trace ! ( msg_name = container_msg. as_ref( ) , "processing" ) ;
1870
1885
1871
1886
match container_msg {
@@ -1885,20 +1900,18 @@ impl Container {
1885
1900
status_tx. send ( stats) . await . ok ( /* Receiver gone, that's OK */ ) ;
1886
1901
}
1887
1902
1888
- WorkerMessage :: Error ( e) =>
1889
- return Err ( SerializedError2 :: adapt( e) ) . context( WorkerSnafu ) ,
1903
+ WorkerMessage :: Error ( e) => {
1904
+ return Err ( SerializedError2 :: adapt ( e) ) . context ( WorkerSnafu ) ;
1905
+ }
1890
1906
1891
- WorkerMessage :: Error2 ( e) =>
1892
- return Err ( e) . context( WorkerSnafu ) ,
1907
+ WorkerMessage :: Error2 ( e) => return Err ( e) . context ( WorkerSnafu ) ,
1893
1908
1894
1909
_ => {
1895
1910
let message = container_msg. as_ref ( ) ;
1896
- return UnexpectedMessageSnafu { message } . fail( )
1897
- } ,
1911
+ return UnexpectedMessageSnafu { message } . fail ( ) ;
1912
+ }
1898
1913
}
1899
- } ,
1900
-
1901
- else => return UnexpectedEndOfMessagesSnafu . fail( ) ,
1914
+ }
1902
1915
}
1903
1916
}
1904
1917
}
0 commit comments