From 6b4ba5ac448fc4e38d61b7ab02889ce1ad943bf8 Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Tue, 28 Jan 2025 21:36:16 +0100 Subject: [PATCH] fix crash when receiving HardReset --- src/udp_server.rs | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/udp_server.rs b/src/udp_server.rs index 1046215..449ad84 100644 --- a/src/udp_server.rs +++ b/src/udp_server.rs @@ -45,7 +45,22 @@ impl<'t> UdpServer<'t> { if let Some(cmd) = self.receive_into_buf().and_then(|amount| { Self::command_from_slice(&self.buf[..amount]) }) { - self.handle_command(cmd); + match self.command_executor.execute(cmd) { + ExecutionResult::Success => { + self.app_events + .send_event(AppEvents::UdpPacketHandled) + .expect("could not send packet handled event"); + } + ExecutionResult::Failure => { + error!("failed to execute command"); + } + ExecutionResult::Shutdown => { + self.app_events + .send_event(AppEvents::UdpThreadClosed) + .expect("could not send close event"); + break; + } + } } } } @@ -81,22 +96,4 @@ impl<'t> UdpServer<'t> { } Some(amount) } - - fn handle_command(&mut self, command: Command) { - match self.command_executor.execute(command) { - ExecutionResult::Success => { - self.app_events - .send_event(AppEvents::UdpPacketHandled) - .expect("could not send packet handled event"); - } - ExecutionResult::Failure => { - error!("failed to execute command"); - } - ExecutionResult::Shutdown => { - self.app_events - .send_event(AppEvents::UdpThreadClosed) - .expect("could not send close event"); - } - } - } }