@@ -56,7 +56,10 @@ async fn inbox_loop(ctx: Context, started: Sender<()>, inbox_handlers: ImapConne
5656
5757 let ctx1 = ctx. clone ( ) ;
5858 let fut = async move {
59- started. send ( ( ) ) . await . unwrap ( ) ;
59+ started
60+ . send ( ( ) )
61+ . await
62+ . expect ( "inbox loop, missing started receiver" ) ;
6063 let ctx = ctx1;
6164
6265 // track number of continously executed jobs
@@ -105,7 +108,10 @@ async fn inbox_loop(ctx: Context, started: Sender<()>, inbox_handlers: ImapConne
105108 } )
106109 . race ( fut)
107110 . await ;
108- shutdown_sender. send ( ( ) ) . await . unwrap ( ) ;
111+ shutdown_sender
112+ . send ( ( ) )
113+ . await
114+ . expect ( "inbox loop, missing shutdown receiver" ) ;
109115}
110116
111117async fn fetch ( ctx : & Context , connection : & mut Imap ) {
@@ -184,7 +190,10 @@ async fn simple_imap_loop(
184190 let ctx1 = ctx. clone ( ) ;
185191
186192 let fut = async move {
187- started. send ( ( ) ) . await . unwrap ( ) ;
193+ started
194+ . send ( ( ) )
195+ . await
196+ . expect ( "simple imap loop, missing started receive" ) ;
188197 let ctx = ctx1;
189198
190199 loop {
@@ -199,7 +208,10 @@ async fn simple_imap_loop(
199208 } )
200209 . race ( fut)
201210 . await ;
202- shutdown_sender. send ( ( ) ) . await . unwrap ( ) ;
211+ shutdown_sender
212+ . send ( ( ) )
213+ . await
214+ . expect ( "simple imap loop, missing shutdown receiver" ) ;
203215}
204216
205217async fn smtp_loop ( ctx : Context , started : Sender < ( ) > , smtp_handlers : SmtpConnectionHandlers ) {
@@ -215,7 +227,10 @@ async fn smtp_loop(ctx: Context, started: Sender<()>, smtp_handlers: SmtpConnect
215227
216228 let ctx1 = ctx. clone ( ) ;
217229 let fut = async move {
218- started. send ( ( ) ) . await . unwrap ( ) ;
230+ started
231+ . send ( ( ) )
232+ . await
233+ . expect ( "smtp loop, missing started receiver" ) ;
219234 let ctx = ctx1;
220235
221236 let mut interrupt_info = Default :: default ( ) ;
@@ -243,7 +258,10 @@ async fn smtp_loop(ctx: Context, started: Sender<()>, smtp_handlers: SmtpConnect
243258 } )
244259 . race ( fut)
245260 . await ;
246- shutdown_sender. send ( ( ) ) . await . unwrap ( ) ;
261+ shutdown_sender
262+ . send ( ( ) )
263+ . await
264+ . expect ( "smtp loop, missing shutdown receiver" ) ;
247265}
248266
249267impl Scheduler {
@@ -278,7 +296,10 @@ impl Scheduler {
278296 . await
279297 } ) ) ;
280298 } else {
281- mvbox_start_send. send ( ( ) ) . await . unwrap ( ) ;
299+ mvbox_start_send
300+ . send ( ( ) )
301+ . await
302+ . expect ( "mvbox start send, missing receiver" ) ;
282303 }
283304
284305 if ctx. get_config_bool ( Config :: SentboxWatch ) . await {
@@ -293,7 +314,10 @@ impl Scheduler {
293314 . await
294315 } ) ) ;
295316 } else {
296- sentbox_start_send. send ( ( ) ) . await . unwrap ( ) ;
317+ sentbox_start_send
318+ . send ( ( ) )
319+ . await
320+ . expect ( "sentbox start send, missing receiver" ) ;
297321 }
298322
299323 let ctx1 = ctx. clone ( ) ;
@@ -370,17 +394,27 @@ impl Scheduler {
370394 }
371395 Scheduler :: Running {
372396 inbox,
397+ inbox_handle,
373398 mvbox,
399+ mvbox_handle,
374400 sentbox,
401+ sentbox_handle,
375402 smtp,
403+ smtp_handle,
376404 ..
377405 } => {
378- inbox
379- . stop ( )
380- . join ( mvbox. stop ( ) )
381- . join ( sentbox. stop ( ) )
382- . join ( smtp. stop ( ) )
383- . await ;
406+ if inbox_handle. is_some ( ) {
407+ inbox. stop ( ) . await ;
408+ }
409+ if mvbox_handle. is_some ( ) {
410+ mvbox. stop ( ) . await ;
411+ }
412+ if sentbox_handle. is_some ( ) {
413+ sentbox. stop ( ) . await ;
414+ }
415+ if smtp_handle. is_some ( ) {
416+ smtp. stop ( ) . await ;
417+ }
384418
385419 StopToken
386420 }
@@ -439,7 +473,10 @@ impl ConnectionState {
439473 /// Shutdown this connection completely.
440474 async fn stop ( & self ) {
441475 // Trigger shutdown of the run loop.
442- self . stop_sender . send ( ( ) ) . await . unwrap ( ) ;
476+ self . stop_sender
477+ . send ( ( ) )
478+ . await
479+ . expect ( "stop, missing receiver" ) ;
443480 // Wait for a notification that the run loop has been shutdown.
444481 self . shutdown_receiver . recv ( ) . await . ok ( ) ;
445482 }
0 commit comments