From f33dd8447d230b566366630a886d01373ad6012c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20Wyszy=C5=84ski?= Date: Fri, 6 Dec 2024 13:21:13 +0100 Subject: [PATCH] fix: separate connection managers for Modbus and HTTP - Add dedicated stats_manager for HTTP API - Keep connection_manager only for Modbus TCP connections - Prevent HTTP connections from being tracked as Modbus connections --- src/modbus_relay.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modbus_relay.rs b/src/modbus_relay.rs index 55ec625..44e8f2d 100644 --- a/src/modbus_relay.rs +++ b/src/modbus_relay.rs @@ -23,6 +23,7 @@ pub struct ModbusRelay { config: RelayConfig, transport: Arc, connection_manager: Arc, + stats_manager: Arc, shutdown: broadcast::Sender<()>, main_shutdown: tokio::sync::watch::Sender, tasks: Arc>>>, @@ -37,6 +38,7 @@ impl ModbusRelay { // Initialize connection manager with connection config from RelayConfig let connection_manager = Arc::new(ConnectionManager::new(config.connection.clone())); + let stats_manager = Arc::new(ConnectionManager::new(config.connection.clone())); let (main_shutdown, _) = tokio::sync::watch::channel(false); @@ -44,6 +46,7 @@ impl ModbusRelay { config, transport: Arc::new(transport), connection_manager, + stats_manager, shutdown: broadcast::channel(1).0, main_shutdown, tasks: Arc::new(Mutex::new(Vec::new())), @@ -173,7 +176,7 @@ impl ModbusRelay { // Start HTTP server if enabled if self.config.http.enabled { let http_server = { - let manager = Arc::clone(&self.connection_manager); + let manager = Arc::clone(&self.stats_manager); let rx = self.shutdown.subscribe(); let config = self.config.clone();