No more freezes?

This commit is contained in:
Shiroyasha 2024-06-11 15:14:07 +03:00
parent 34905701a0
commit 5eedf26ca8
Signed by: shiroyashik
GPG key ID: E4953D3940D7860A

View file

@ -146,7 +146,7 @@ async fn handle_socket(mut socket: WebSocket, state: AppState) {
rx rx
}, },
}; };
// .to_owned().subscribe();
let shutdown = Arc::new(Notify::new()); let shutdown = Arc::new(Notify::new());
tokio::spawn(subscribe(mtx.clone(), rx, shutdown.clone())); tokio::spawn(subscribe(mtx.clone(), rx, shutdown.clone()));
cutoff.insert(uuid, shutdown); cutoff.insert(uuid, shutdown);
@ -206,21 +206,17 @@ async fn subscribe(
return; return;
} }
msg = rx.recv() => { msg = rx.recv() => {
let msg = msg.ok(); let msg = msg.ok();
if let Some(msg) = msg { if let Some(msg) = msg {
// debug!("[WebSocketSubscriber] Received: {msg}");
if socket.send(msg.clone()).await.is_err() { if socket.send(msg.clone()).await.is_err() {
error!("Forced shutdown SUB due error!"); error!("Forced shutdown SUB! Reciever closed connection?");
return; return;
}; };
} else {
error!("Forced shutdown SUB! Sender closed connection?");
return;
} }
// if socket.send(msg.unwrap()).await.is_err() {
// error!("Forced shutdown SUB due error!");
// return;
// };
} }
} }
} }