Explorar o código

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

epiphany hai 1 ano
pai
achega
8660540b97
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  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 },