mirror of
https://github.com/chatmail/core.git
synced 2026-05-22 16:26:31 +03:00
fix: do not take write lock for maybe_network_lost() and set_push_device_token()
This commit is contained in:
@@ -4868,7 +4868,7 @@ pub unsafe extern "C" fn dc_accounts_maybe_network_lost(accounts: *mut dc_accoun
|
|||||||
}
|
}
|
||||||
|
|
||||||
let accounts = &*accounts;
|
let accounts = &*accounts;
|
||||||
block_on(async move { accounts.write().await.maybe_network_lost().await });
|
block_on(async move { accounts.read().await.maybe_network_lost().await });
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
@@ -4905,7 +4905,7 @@ pub unsafe extern "C" fn dc_accounts_set_push_device_token(
|
|||||||
let token = to_string_lossy(token);
|
let token = to_string_lossy(token);
|
||||||
|
|
||||||
block_on(async move {
|
block_on(async move {
|
||||||
let mut accounts = accounts.write().await;
|
let accounts = accounts.read().await;
|
||||||
if let Err(err) = accounts.set_push_device_token(&token).await {
|
if let Err(err) = accounts.set_push_device_token(&token).await {
|
||||||
accounts.emit_event(EventType::Error(format!(
|
accounts.emit_event(EventType::Error(format!(
|
||||||
"Failed to set notify token: {err:#}."
|
"Failed to set notify token: {err:#}."
|
||||||
|
|||||||
@@ -344,7 +344,7 @@ impl Accounts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Sets notification token for Apple Push Notification service.
|
/// Sets notification token for Apple Push Notification service.
|
||||||
pub async fn set_push_device_token(&mut self, token: &str) -> Result<()> {
|
pub async fn set_push_device_token(&self, token: &str) -> Result<()> {
|
||||||
self.push_subscriber.set_device_token(token).await;
|
self.push_subscriber.set_device_token(token).await;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ impl PushSubscriber {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Sets device token for Apple Push Notification service.
|
/// Sets device token for Apple Push Notification service.
|
||||||
pub(crate) async fn set_device_token(&mut self, token: &str) {
|
pub(crate) async fn set_device_token(&self, token: &str) {
|
||||||
self.inner.write().await.device_token = Some(token.to_string());
|
self.inner.write().await.device_token = Some(token.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user