Răsfoiți Sursa

dht: fix `get_channel()` holding a write lock to the channel cache for too long

epiphany 1 an în urmă
părinte
comite
8660540b97
1 a modificat fișierele cu 3 adăugiri și 0 ștergeri
  1. 3 0
      src/dht/handler.rs

+ 3 - 0
src/dht/handler.rs

@@ -355,6 +355,8 @@ pub trait DhtHandler {
             }
         }
 
+        drop(channel_cache);
+
         // Create a channel
         for addr in node.addresses.clone() {
             let session_out = self.dht().p2p.session_outbound();
@@ -387,6 +389,7 @@ pub trait DhtHandler {
                 continue;
             }
 
+            let mut channel_cache = channel_cache_lock.write().await;
             channel_cache.insert(
                 channel.info.id,
                 ChannelCacheItem { node: node.clone(), topic, usage_count: 1 },