Skip to content

Commit a46c77a

Browse files
committed
fix: Avoid lock reentrancy on Generic FFI's conversation_create causing deadlocks
1 parent 28b7cde commit a46c77a

File tree

1 file changed

+11
-25
lines changed

1 file changed

+11
-25
lines changed

crypto-ffi/src/generic.rs

+11-25
Original file line numberDiff line numberDiff line change
@@ -793,22 +793,6 @@ pub async fn core_crypto_deferred_init(
793793
.into())
794794
}
795795

796-
#[allow(dead_code, unused_variables)]
797-
impl CoreCrypto {
798-
async fn lower_cfg(&self, cfg: ConversationConfiguration) -> CoreCryptoResult<MlsConversationConfiguration> {
799-
let mut lower_cfg = MlsConversationConfiguration {
800-
custom: cfg.custom.into(),
801-
ciphersuite: cfg.ciphersuite.into(),
802-
..Default::default()
803-
};
804-
self.central
805-
.lock()
806-
.await
807-
.set_raw_external_senders(&mut lower_cfg, cfg.external_senders)?;
808-
Ok(lower_cfg)
809-
}
810-
}
811-
812796
#[allow(dead_code, unused_variables)]
813797
#[uniffi::export]
814798
impl CoreCrypto {
@@ -986,15 +970,17 @@ impl CoreCrypto {
986970
creator_credential_type: MlsCredentialType,
987971
config: ConversationConfiguration,
988972
) -> CoreCryptoResult<()> {
989-
Ok(self
990-
.central
991-
.lock()
992-
.await
993-
.new_conversation(
994-
&conversation_id,
995-
creator_credential_type.into(),
996-
self.lower_cfg(config).await?,
997-
)
973+
let mut central = self.central.lock().await;
974+
let mut lower_cfg = MlsConversationConfiguration {
975+
custom: config.custom.into(),
976+
ciphersuite: config.ciphersuite.into(),
977+
..Default::default()
978+
};
979+
980+
central.set_raw_external_senders(&mut lower_cfg, config.external_senders)?;
981+
982+
Ok(central
983+
.new_conversation(&conversation_id, creator_credential_type.into(), lower_cfg)
998984
.await?)
999985
}
1000986

0 commit comments

Comments
 (0)