From 232d367461432df21d9601a66aa8bf44580f16e9 Mon Sep 17 00:00:00 2001 From: andig Date: Mon, 10 Aug 2026 17:25:08 +0200 Subject: [PATCH] chore: don't guard connection settings with the registry mutex (#32695) --- util/modbus/modbus.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/util/modbus/modbus.go b/util/modbus/modbus.go index c332d41f6..7e66db687 100644 --- a/util/modbus/modbus.go +++ b/util/modbus/modbus.go @@ -104,7 +104,7 @@ type meterConnection struct { proto Protocol refs int // count of references; first connection has ref count 0 - // largest value requested by any of the sharing logical connections + mu sync.Mutex delay time.Duration connectDelay time.Duration timeout time.Duration @@ -114,23 +114,23 @@ type meterConnection struct { // setDelay applies the delay if larger than the current value func (c *meterConnection) setDelay(delay time.Duration) { - mu.Lock() - defer mu.Unlock() + c.mu.Lock() + defer c.mu.Unlock() c.delay = max(c.delay, delay) } func (c *meterConnection) getDelay() time.Duration { - mu.Lock() - defer mu.Unlock() + c.mu.Lock() + defer c.mu.Unlock() return c.delay } // setConnectDelay applies the connect delay if larger than the current value func (c *meterConnection) setConnectDelay(delay time.Duration) { - mu.Lock() - defer mu.Unlock() + c.mu.Lock() + defer c.mu.Unlock() if delay > c.connectDelay { c.connectDelay = delay @@ -140,8 +140,8 @@ func (c *meterConnection) setConnectDelay(delay time.Duration) { // setTimeout applies the timeout if larger than the current value func (c *meterConnection) setTimeout(timeout time.Duration) { - mu.Lock() - defer mu.Unlock() + c.mu.Lock() + defer c.mu.Unlock() if timeout > c.timeout { c.timeout = timeout