diff options
| author | Eskil Q <eskilq@kth.se> | 2021-01-06 23:50:09 +0100 |
|---|---|---|
| committer | Eskil Q <eskilq@kth.se> | 2021-01-06 23:50:09 +0100 |
| commit | 92d5b21bf0f910f219c473002f83ba93ddcbee6d (patch) | |
| tree | 5280eb78c1e75e711ba5091c4ddeb6fa0ac79f69 /mumd/src/command.rs | |
| parent | 02e6f2b84d72294b29a1698c1b73fbb5697815da (diff) | |
| download | mum-92d5b21bf0f910f219c473002f83ba93ddcbee6d.tar.gz | |
fix deadlock
Diffstat (limited to 'mumd/src/command.rs')
| -rw-r--r-- | mumd/src/command.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/mumd/src/command.rs b/mumd/src/command.rs index e77b34b..b099ae1 100644 --- a/mumd/src/command.rs +++ b/mumd/src/command.rs @@ -9,8 +9,8 @@ use ipc_channel::ipc::IpcSender; use log::*; use mumble_protocol::{Serverbound, control::ControlPacket}; use mumlib::command::{Command, CommandResponse}; -use std::sync::{Arc, Mutex}; -use tokio::sync::{mpsc, oneshot, watch}; +use std::sync::Arc; +use tokio::sync::{mpsc, oneshot, watch, Mutex}; pub async fn handle( state: Arc<Mutex<State>>, @@ -26,9 +26,11 @@ pub async fn handle( debug!("Begin listening for commands"); while let Some((command, response_sender)) = command_receiver.recv().await { debug!("Received command {:?}", command); - let mut state = state.lock().unwrap(); + debug!("locking state"); + let mut state = state.lock().await; let event = state.handle_command(command, &mut packet_sender, &mut connection_info_sender); drop(state); + debug!("unlocking state"); match event { ExecutionContext::TcpEvent(event, generator) => { let (tx, rx) = oneshot::channel(); |
