mirror of
https://github.com/chatmail/core.git
synced 2026-05-04 05:46:29 +03:00
mimeparser: wrap try_decrypt() into block_in_place()
try_decrypt() is a CPU-bound task. When called from async function, it should be wrapped in tokio::task::spawn_blocking(). Using tokio::task::spawn_blocking() is difficult here because of &mail, &private_keyring and &public_keyring borrows, so we should at least use tokio::task::block_in_place() to avoid blocking the executor.
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
- Make smeared timestamp generation non-async. #4075
|
- Make smeared timestamp generation non-async. #4075
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
|
- Do not block async task executor while decrypting the messages. #4079
|
||||||
|
|
||||||
### API-Changes
|
### API-Changes
|
||||||
|
|
||||||
|
|||||||
@@ -256,8 +256,9 @@ impl MimeMessage {
|
|||||||
hop_info += &decryption_info.dkim_results.to_string();
|
hop_info += &decryption_info.dkim_results.to_string();
|
||||||
|
|
||||||
let public_keyring = keyring_from_peerstate(decryption_info.peerstate.as_ref());
|
let public_keyring = keyring_from_peerstate(decryption_info.peerstate.as_ref());
|
||||||
let (mail, mut signatures, encrypted) =
|
let (mail, mut signatures, encrypted) = match tokio::task::block_in_place(|| {
|
||||||
match try_decrypt(context, &mail, &private_keyring, &public_keyring) {
|
try_decrypt(context, &mail, &private_keyring, &public_keyring)
|
||||||
|
}) {
|
||||||
Ok(Some((raw, signatures))) => {
|
Ok(Some((raw, signatures))) => {
|
||||||
mail_raw = raw;
|
mail_raw = raw;
|
||||||
let decrypted_mail = mailparse::parse_mail(&mail_raw)?;
|
let decrypted_mail = mailparse::parse_mail(&mail_raw)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user