From b156b43b0994017636b153abceb78d86542047d7 Mon Sep 17 00:00:00 2001 From: Eskil Queseth Date: Thu, 15 Oct 2020 22:11:08 +0200 Subject: change loop to avoid panic --- mumd/src/command.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'mumd/src/command.rs') diff --git a/mumd/src/command.rs b/mumd/src/command.rs index 6314870..57eaaa3 100644 --- a/mumd/src/command.rs +++ b/mumd/src/command.rs @@ -11,22 +11,16 @@ pub async fn handle( mut command_receiver: mpsc::UnboundedReceiver<(Command, IpcSender>>)>, ) { debug!("Begin listening for commands"); - loop { - debug!("Enter loop"); - let command = command_receiver.recv().await.unwrap(); + while let Some(command) = command_receiver.recv().await { debug!("Received command {:?}", command.0); let mut state = state.lock().unwrap(); - debug!("Got mutex lock"); let (wait_for_connected, command_response) = state.handle_command(command.0).await; if wait_for_connected { let mut watcher = state.phase_receiver(); drop(state); - debug!("Waiting to be connected"); while !matches!(watcher.recv().await.unwrap(), StatePhase::Connected) {} } - debug!("Sending response"); command.1.send(command_response).unwrap(); - debug!("Sent response"); } //TODO err if not connected //while let Some(command) = command_receiver.recv().await { -- cgit v1.2.1