mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 17:36:29 +03:00
allow calls to start_io when already running and to stop_io when not running, only log a message in these cases
This commit is contained in:
@@ -497,8 +497,8 @@ int dc_is_configured (const dc_context_t* context);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Start job and IMAP/SMTP tasks.
|
* Start job and IMAP/SMTP tasks.
|
||||||
* You must not call dc_start_io() if IO is already started,
|
* If IO is already running, nothing happens.
|
||||||
* please check the current state using dc_is_io_running() first.
|
* To check the current IO state, use dc_is_io_running().
|
||||||
*
|
*
|
||||||
* @memberof dc_context_t
|
* @memberof dc_context_t
|
||||||
* @param context The context object as created by dc_context_new().
|
* @param context The context object as created by dc_context_new().
|
||||||
@@ -518,6 +518,8 @@ int dc_is_io_running(const dc_context_t* context);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop job and IMAP/SMTP tasks and return when they are finished.
|
* Stop job and IMAP/SMTP tasks and return when they are finished.
|
||||||
|
* If IO is not running, nothing happens.
|
||||||
|
* To check the current IO state, use dc_is_io_running().
|
||||||
*
|
*
|
||||||
* @memberof dc_context_t
|
* @memberof dc_context_t
|
||||||
* @param context The context object as created by dc_context_new().
|
* @param context The context object as created by dc_context_new().
|
||||||
|
|||||||
@@ -138,7 +138,10 @@ impl Context {
|
|||||||
/// Starts the IO scheduler.
|
/// Starts the IO scheduler.
|
||||||
pub async fn start_io(&self) {
|
pub async fn start_io(&self) {
|
||||||
info!(self, "starting IO");
|
info!(self, "starting IO");
|
||||||
assert!(!self.is_io_running().await, "context is already running");
|
if self.is_io_running().await {
|
||||||
|
info!(self, "IO is already running");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let l = &mut *self.inner.scheduler.write().await;
|
let l = &mut *self.inner.scheduler.write().await;
|
||||||
l.start(self.clone()).await;
|
l.start(self.clone()).await;
|
||||||
@@ -152,6 +155,11 @@ impl Context {
|
|||||||
/// Stops the IO scheduler.
|
/// Stops the IO scheduler.
|
||||||
pub async fn stop_io(&self) {
|
pub async fn stop_io(&self) {
|
||||||
info!(self, "stopping IO");
|
info!(self, "stopping IO");
|
||||||
|
if !self.is_io_running().await {
|
||||||
|
info!(self, "IO is not running");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
self.inner.stop_io().await;
|
self.inner.stop_io().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user