aboutsummaryrefslogtreecommitdiffstats
path: root/mumd/src
diff options
context:
space:
mode:
Diffstat (limited to 'mumd/src')
-rw-r--r--mumd/src/command.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/mumd/src/command.rs b/mumd/src/command.rs
index 73ab3bd..2a3f148 100644
--- a/mumd/src/command.rs
+++ b/mumd/src/command.rs
@@ -4,10 +4,7 @@ use crate::state::{ExecutionContext, State};
use log::*;
use mumble_protocol::{control::ControlPacket, Serverbound};
use mumlib::command::{Command, CommandResponse};
-use std::sync::{
- atomic::{AtomicU64, Ordering},
- Arc, RwLock,
-};
+use std::{rc::Rc, sync::{Arc, RwLock, atomic::{AtomicBool, AtomicU64, Ordering}}};
use tokio::sync::{mpsc, watch};
pub async fn handle(
@@ -33,14 +30,18 @@ pub async fn handle(
);
match event {
ExecutionContext::TcpEventCallback(callbacks) => {
+ let should_handle = Rc::new(AtomicBool::new(true));
for (event, generator) in callbacks {
+ let should_handle = Rc::clone(&should_handle);
let response_sender = response_sender.clone();
tcp_event_queue.register_callback(
event,
Box::new(move |e| {
- let response = generator(e);
- for response in response {
- response_sender.send(response).unwrap();
+ if should_handle.fetch_and(false, Ordering::Relaxed) {
+ let response = generator(e);
+ for response in response {
+ response_sender.send(response).unwrap();
+ }
}
}),
);