From 6bf2c5415f4e532c4c1fe6124ca672291dcf48f2 Mon Sep 17 00:00:00 2001 From: link2xt Date: Sat, 23 Apr 2022 10:48:37 +0000 Subject: [PATCH] Don't count IMAP jobs in scheduler The limit on the number of jobs executed in a row was introduced to prevent large queues of small jobs like MarkseenMsgOnImap, MoveMsg and DeleteMsgOnImap from delaying message fetching. Since all these jobs are now removed and IMAP operations they did are now batched, it is impossible to have 20 or more queued IMAP jobs. --- src/scheduler.rs | 42 +----------------------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/src/scheduler.rs b/src/scheduler.rs index 725e1c6be..4893bb613 100644 --- a/src/scheduler.rs +++ b/src/scheduler.rs @@ -87,8 +87,6 @@ async fn inbox_loop(ctx: Context, started: Sender<()>, inbox_handlers: ImapConne .expect("inbox loop, missing started receiver"); let ctx = ctx1; - // track number of continously executed jobs - let mut jobs_loaded = 0; let mut info = InterruptInfo::default(); loop { let job = match job::load_next(&ctx, Thread::Imap, &info).await { @@ -100,20 +98,11 @@ async fn inbox_loop(ctx: Context, started: Sender<()>, inbox_handlers: ImapConne }; match job { - Some(job) if jobs_loaded <= 20 => { - jobs_loaded += 1; + Some(job) => { job::perform_job(&ctx, job::Connection::Inbox(&mut connection), job).await; info = Default::default(); } - Some(job) => { - // Let the fetch run, but return back to the job afterwards. - jobs_loaded = 0; - info!(ctx, "postponing imap-job {} to run fetch...", job); - fetch(&ctx, &mut connection).await; - } None => { - jobs_loaded = 0; - maybe_add_time_based_warnings(&ctx).await; match ctx.get_config_i64(Config::LastHousekeeping).await { @@ -148,35 +137,6 @@ async fn inbox_loop(ctx: Context, started: Sender<()>, inbox_handlers: ImapConne .expect("inbox loop, missing shutdown receiver"); } -async fn fetch(ctx: &Context, connection: &mut Imap) { - match ctx.get_config(Config::ConfiguredInboxFolder).await { - Ok(Some(watch_folder)) => { - if let Err(err) = connection.prepare(ctx).await { - warn!(ctx, "Could not connect: {}", err); - return; - } - - // fetch - if let Err(err) = connection - .fetch_move_delete(ctx, &watch_folder, false) - .await - { - connection.trigger_reconnect(ctx).await; - warn!(ctx, "{:#}", err); - } - } - Ok(None) => { - info!(ctx, "Can not fetch inbox folder, not set"); - } - Err(err) => { - warn!( - ctx, - "Can not fetch inbox folder, failed to get config: {:?}", err - ); - } - } -} - async fn fetch_idle(ctx: &Context, connection: &mut Imap, folder: Config) -> InterruptInfo { match ctx.get_config(folder).await { Ok(Some(watch_folder)) => {