From 34f7ff58ee2afc197751019305abdc8c83d80a6b Mon Sep 17 00:00:00 2001 From: Jackson Xu Date: Fri, 3 Jul 2026 11:30:37 +0800 Subject: [PATCH] modbus: limit link error-recovery sleep+flush to confirmations ETIMEDOUT triggers _sleep_response_timeout() + modbus_flush() regardless of msg_type. On the indication path this stalls a non-blocking server for response_timeout and can flush a client request that arrives during the sleep window, dropping it silently. Scope the recovery to MSG_CONFIRMATION, matching the client-side retry intent it was written for. --- src/modbus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modbus.c b/src/modbus.c index abdd718c..d371d6da 100644 --- a/src/modbus.c +++ b/src/modbus.c @@ -444,7 +444,7 @@ int _modbus_receive_msg(modbus_t *ctx, uint8_t *msg, msg_type_t msg_type) #else int saved_errno = errno; - if (errno == ETIMEDOUT) { + if (errno == ETIMEDOUT && msg_type == MSG_CONFIRMATION) { _sleep_response_timeout(ctx); modbus_flush(ctx); } else if (errno == EBADF) {