From d4c9bcdd37fcc9d34eae175fbefacfb6bff03724 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Villac=C3=ADs=20Lasso?= Date: Fri, 2 Sep 2022 17:52:50 -0500 Subject: [PATCH] Prevent spurious RX timeout/close on incoming socket object When accepting a socket from an incoming connection, the internal fd was assigned without updating the field for last RX activity. If the remote side did *not* immediately write to the connection, or otherwise the socket could not be internally checked for incoming data, AND the higher-level code set up a RX timeout value, the 125-ms interval polling might evaluate the socket RX timeout condition with a last RX activity timestamp of zero (as per the default constructor). This caused a spurious RX timeout and incorrect socket closing. Fixed by initializing the field when the new incoming connection socket is accepted. --- src/AsyncTCP.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/AsyncTCP.cpp b/src/AsyncTCP.cpp index 345fa3a..d39a8aa 100644 --- a/src/AsyncTCP.cpp +++ b/src/AsyncTCP.cpp @@ -307,6 +307,7 @@ AsyncClient::AsyncClient(int sockfd) xSemaphoreTakeRecursive(_asyncsock_mutex, (TickType_t)portMAX_DELAY); _conn_state = 4; _socket = sockfd; + _rx_last_packet = millis(); xSemaphoreGiveRecursive(_asyncsock_mutex); } }