Bladeren bron

Remove read/write locks

Remove a read lock to check and avoid two consecutive write locks.
Cesar Rodas 2 jaren geleden
bovenliggende
commit
71b41d053c
2 gewijzigde bestanden met toevoegingen van 1 en 4 verwijderingen
  1. 1 0
      src/connection/pubsub_connection.rs
  2. 0 4
      src/connection/pubsub_server.rs

+ 1 - 0
src/connection/pubsub_connection.rs

@@ -102,6 +102,7 @@ impl PubsubClient {
     /// Creates a new pattern subscription
     /// Creates a new pattern subscription
     pub fn new_psubscription(&self, channel: &Pattern) {
     pub fn new_psubscription(&self, channel: &Pattern) {
         let mut meta = self.meta.write();
         let mut meta = self.meta.write();
+        meta.is_psubcribed = true;
         meta.psubscriptions.insert(channel.clone(), true);
         meta.psubscriptions.insert(channel.clone(), true);
     }
     }
 
 

+ 0 - 4
src/connection/pubsub_server.rs

@@ -74,10 +74,6 @@ impl Pubsub {
                 h.insert(conn.id(), conn.pubsub_client().sender());
                 h.insert(conn.id(), conn.pubsub_client().sender());
                 subscriptions.insert(channel.clone(), h);
                 subscriptions.insert(channel.clone(), h);
             }
             }
-            if !conn.pubsub_client().is_psubcribed() {
-                conn.pubsub_client().make_psubcribed();
-            }
-
             conn.pubsub_client().new_psubscription(&channel);
             conn.pubsub_client().new_psubscription(&channel);
 
 
             conn.append_response(
             conn.append_response(