diff options
| author | Rubens Brandao <git@rubens.io> | 2021-04-05 16:04:19 +0200 |
|---|---|---|
| committer | Rubens Brandao <git@rubens.io> | 2021-04-09 20:00:15 +0200 |
| commit | a39934e562fd2755fcb7b1ed271bcf3f31aaa0d5 (patch) | |
| tree | 18bb7644fb95946ebf1c0f284b0f92bbe8eae6d8 /mumd/src/command.rs | |
| parent | 07d06b6946e23ecffbf5549376cf464013222274 (diff) | |
| download | mum-a39934e562fd2755fcb7b1ed271bcf3f31aaa0d5.tar.gz | |
Replace State tokio::sync::Mutex by std::sync::RwLock
Diffstat (limited to 'mumd/src/command.rs')
| -rw-r--r-- | mumd/src/command.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/mumd/src/command.rs b/mumd/src/command.rs index 3e462b1..7eec388 100644 --- a/mumd/src/command.rs +++ b/mumd/src/command.rs @@ -8,11 +8,11 @@ use crate::state::{ExecutionContext, State}; use log::*; use mumble_protocol::{Serverbound, control::ControlPacket}; use mumlib::command::{Command, CommandResponse}; -use std::sync::Arc; -use tokio::sync::{mpsc, oneshot, watch, Mutex}; +use std::sync::{Arc, RwLock}; +use tokio::sync::{mpsc, oneshot, watch}; pub async fn handle( - state: Arc<Mutex<State>>, + state: Arc<RwLock<State>>, mut command_receiver: mpsc::UnboundedReceiver<( Command, oneshot::Sender<mumlib::error::Result<Option<CommandResponse>>>, @@ -25,7 +25,7 @@ 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().await; + let mut state = state.write().unwrap(); let event = state.handle_command(command, &mut packet_sender, &mut connection_info_sender); drop(state); match event { |
