Process PerformJobsNeeded::AvoidDos case explicitly

This commit is contained in:
Alexander Krotov
2019-11-28 16:33:48 +01:00
committed by Floris Bruynooghe
parent 95b90a59dc
commit 02fe3d1b99

View File

@@ -508,24 +508,27 @@ pub fn perform_smtp_idle(context: &Context) {
let &(ref lock, ref cvar) = &*context.smtp_state.clone(); let &(ref lock, ref cvar) = &*context.smtp_state.clone();
let mut state = lock.lock().unwrap(); let mut state = lock.lock().unwrap();
if state.perform_jobs_needed == PerformJobsNeeded::AtOnce { match state.perform_jobs_needed {
info!( PerformJobsNeeded::AtOnce => {
context, info!(
"SMTP-idle will not be started because of waiting jobs.", context,
); "SMTP-idle will not be started because of waiting jobs.",
} else { );
let dur = get_next_wakeup_time(context, Thread::Smtp); }
PerformJobsNeeded::Not | PerformJobsNeeded::AvoidDos => {
loop { let dur = get_next_wakeup_time(context, Thread::Smtp);
let res = cvar.wait_timeout(state, dur).unwrap();
state = res.0; loop {
let res = cvar.wait_timeout(state, dur).unwrap();
if state.idle || res.1.timed_out() { state = res.0;
// We received the notification and the value has been updated, we can leave.
break; if state.idle || res.1.timed_out() {
} // We received the notification and the value has been updated, we can leave.
break;
}
}
state.idle = false;
} }
state.idle = false;
} }
} }