mirror of
https://github.com/chatmail/core.git
synced 2026-04-20 23:16:30 +03:00
Fix race condition in alloc_ongoing()
Hold the same write lock while checking if ongoing process is already allocated and while allocating it. Otherwise it is possible for two parallel processes running alloc_ongoing() to decide that no ongoing process is allocated and allocate two ongoing processes.
This commit is contained in:
@@ -741,7 +741,6 @@ mod tests {
|
||||
);
|
||||
|
||||
let sent = bob.pop_sent_msg().await;
|
||||
assert!(!bob.ctx.has_ongoing().await);
|
||||
assert_eq!(sent.recipient(), "alice@example.org".parse().unwrap());
|
||||
let msg = alice.parse_msg(&sent).await;
|
||||
assert!(!msg.was_encrypted());
|
||||
@@ -1291,7 +1290,6 @@ mod tests {
|
||||
let bob_chat = Chat::load_from_db(&bob.ctx, bob_chatid).await?;
|
||||
assert!(bob_chat.is_protected());
|
||||
assert!(bob_chat.typ == Chattype::Group);
|
||||
assert!(!bob.ctx.has_ongoing().await);
|
||||
|
||||
// On this "happy path", Alice and Bob get only a group-chat where all information are added to.
|
||||
// The one-to-one chats are used internally for the hidden handshake messages,
|
||||
|
||||
Reference in New Issue
Block a user