From 3b172dcb2849d084f10cb1995bc339e0b0403e81 Mon Sep 17 00:00:00 2001 From: hongcha Date: Fri, 22 Dec 2023 20:47:52 +0800 Subject: [PATCH] refactor: select layer lock --- src/forward/forward_internal.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/forward/forward_internal.rs b/src/forward/forward_internal.rs index eade02a2..7ed76d0c 100644 --- a/src/forward/forward_internal.rs +++ b/src/forward/forward_internal.rs @@ -246,12 +246,15 @@ impl PeerForwardInternal { if track_remote_original.0.kind() != RTPCodecType::Video { continue; } - let mut subscription_group = - track_forward_original.subscription_group.write().await; + let subscription_group = + track_forward_original.subscription_group.read().await; if subscription_group.contains_key(&peer) { if track_remote_original.0.rid() == rid { return Ok(()); } + drop(subscription_group); + let mut subscription_group = + track_forward_original.subscription_group.write().await; let sender = subscription_group.remove(&peer).unwrap(); drop(subscription_group); track_forward