From 0777dc7896365ff50ac402c8f65cbc826aa34c69 Mon Sep 17 00:00:00 2001 From: Gann <1354410847@qq.com> Date: Tue, 6 Feb 2024 20:31:08 +0800 Subject: [PATCH] Improve error handling in connSocketBlockingConnect for various connction failures (#13008) This commit addresses a problem in connSocketBlockingConnect where different types of connection failures, including timeouts and other errors, were not consistently handled. Previously, the function did not return C_ERR immediately after detecting a connection failure, which could lead to inconsistent states and misinterpretation of the connection status. With this update, connSocketBlockingConnect now correctly returns C_ERR upon encountering any connection error, ensuring that all types of connection failures are handled consistently and the behavior of the function aligns with expected outcomes in case of connection issues. Closes #12900 --- src/socket.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/socket.c b/src/socket.c index 61a2b9ea9..775d56d37 100644 --- a/src/socket.c +++ b/src/socket.c @@ -361,6 +361,7 @@ static int connSocketBlockingConnect(connection *conn, const char *addr, int por if ((aeWait(fd, AE_WRITABLE, timeout) & AE_WRITABLE) == 0) { conn->state = CONN_STATE_ERROR; conn->last_errno = ETIMEDOUT; + return C_ERR; } conn->fd = fd;