diff --git a/bin/ircd/src/main.rs b/bin/ircd/src/main.rs index 597d4a46e..7dcde4850 100644 --- a/bin/ircd/src/main.rs +++ b/bin/ircd/src/main.rs @@ -79,7 +79,7 @@ impl Ircd { .detach(); } - async fn process( + async fn process_new_connection( &self, executor: Arc>, stream: TcpStream, @@ -109,6 +109,7 @@ impl Ircd { .spawn(async move { loop { let mut line = String::new(); + let result: Result<()> = futures::select! { msg = receiver.receive().fuse() => { match conn.process_msg_from_p2p(&msg).await { @@ -235,7 +236,8 @@ async fn realmain(settings: Args, executor: Arc>) -> Result<()> { } }; - let result = ircd.process(executor_cloned.clone(), stream, peer_addr).await; + let result = + ircd.process_new_connection(executor_cloned.clone(), stream, peer_addr).await; if let Err(e) = result { error!("Failed processing connection {}: {}", peer_addr, e); diff --git a/bin/ircd/src/server.rs b/bin/ircd/src/server.rs index 35bdc7189..391debe50 100644 --- a/bin/ircd/src/server.rs +++ b/bin/ircd/src/server.rs @@ -300,13 +300,15 @@ impl IrcServerConnection { } // Send dm messages in buffer - if !self.capabilities.get("no-history").unwrap() { - for msg in self.privmsgs_buffer.lock().await.to_vec() { - if msg.target == self.nickname || - (msg.nickname == self.nickname && !msg.target.starts_with("#")) - { - self.senders.notify_by_id(msg, self.subscriber_id).await; - } + if *self.capabilities.get("no-history").unwrap() { + return Ok(()) + } + + for msg in self.privmsgs_buffer.lock().await.to_vec() { + if msg.target == self.nickname || + (msg.nickname == self.nickname && !msg.target.starts_with("#")) + { + self.senders.notify_by_id(msg, self.subscriber_id).await; } } } @@ -363,6 +365,7 @@ impl IrcServerConnection { (*self.seen_msg_ids.lock().await).push(random_id); (*self.privmsgs_buffer.lock().await).push(protocol_msg.clone()) } + self.senders.notify_with_exclude(protocol_msg.clone(), &[self.subscriber_id]).await; debug!(target: "ircd", "PRIVMSG to be sent: {:?}", protocol_msg); @@ -469,8 +472,6 @@ impl IrcServerConnection { info!("Received msg from IRC client: {:?}", line); let irc_msg = self.clean_input_line(line)?; - info!("Send msg to IRC client '{}' from {}", irc_msg, self.peer_address); - if let Err(e) = self.update(irc_msg).await { warn!("Connection error: {} for {}", e, self.peer_address); return Err(Error::ChannelStopped)