Explorar el Código

system/subscriber: use warn msg instead of panic once notify call failed

ghassmo hace 4 años
padre
commit
e5bde0c6d1
Se han modificado 2 ficheros con 6 adiciones y 5 borrados
  1. 1 1
      bin/ircd/src/server.rs
  2. 5 4
      src/system/subscriber.rs

+ 1 - 1
bin/ircd/src/server.rs

@@ -136,7 +136,7 @@ impl IrcServerConnection {
                     // Send messages in buffer
                     for msg in self.privmsgs_buffer.lock().await.to_vec() {
                         if msg.channel == chan {
-                            self.senders.notify_with_id(msg, self.subscriber_id).await;
+                            self.senders.notify_by_id(msg, self.subscriber_id).await;
                         }
                     }
                 }

+ 5 - 4
src/system/subscriber.rs

@@ -2,6 +2,7 @@ use async_std::sync::Mutex;
 use std::sync::Arc;
 
 use fxhash::FxHashMap;
+use log::warn;
 use rand::Rng;
 
 pub type SubscriberPtr<T> = Arc<Subscriber<T>>;
@@ -70,18 +71,18 @@ impl<T: Clone> Subscriber<T> {
             match sub.send(message_result.clone()).await {
                 Ok(()) => {}
                 Err(err) => {
-                    panic!("Error returned sending message in notify() call! {}", err);
+                    warn!("Error returned sending message in notify() call! {}", err);
                 }
             }
         }
     }
 
-    pub async fn notify_with_id(&self, message_result: T, id: u64) {
+    pub async fn notify_by_id(&self, message_result: T, id: u64) {
         if let Some(sub) = (*self.subs.lock().await).get(&id) {
             match sub.send(message_result.clone()).await {
                 Ok(()) => {}
                 Err(err) => {
-                    panic!("Error returned sending message in notify() call! {}", err);
+                    warn!("Error returned sending message in notify_by_id() call! {}", err);
                 }
             }
         }
@@ -95,7 +96,7 @@ impl<T: Clone> Subscriber<T> {
             match sub.send(message_result.clone()).await {
                 Ok(()) => {}
                 Err(err) => {
-                    panic!("Error returned sending message in notify_with_exclude() call! {}", err);
+                    warn!("Error returned sending message in notify_with_exclude() call! {}", err);
                 }
             }
         }