From 2a090d49b45eafe62c2f212b0848f33f047e9969 Mon Sep 17 00:00:00 2001 From: Bruce Date: Tue, 1 Oct 2024 16:20:13 +0000 Subject: [PATCH] fix socket connect timeout after error --- moon-src/core/network/socket_server.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/moon-src/core/network/socket_server.cpp b/moon-src/core/network/socket_server.cpp index 7bb1c29d..f13ee3db 100644 --- a/moon-src/core/network/socket_server.cpp +++ b/moon-src/core/network/socket_server.cpp @@ -216,7 +216,7 @@ void socket_server::connect( const asio::error_code& ec, tcp::resolver::results_type results ) mutable { - if (params->millseconds > 0 && conn.use_count() == 1) // has timeout timer + if (params->millseconds > 0 && conn.use_count() == 1) // Already timed out return; if (!ec) { @@ -227,7 +227,7 @@ void socket_server::connect( [this, params, conn = std::move(conn)](const asio::error_code& ec, const tcp::endpoint&) { - if (params->millseconds > 0 && conn.use_count() == 1) // has timeout timer + if (params->millseconds > 0 && conn.use_count() == 1) // Already timed out return; if (!ec) { @@ -242,6 +242,8 @@ void socket_server::connect( PTYPE_INTEGER ); } else { + //Set the fd flag to prevent timeout handling + conn->fd(std::numeric_limits::max()); response( 0, params->owner, @@ -259,6 +261,8 @@ void socket_server::connect( } ); } else { + //Set the fd flag to prevent timeout handling + conn->fd(std::numeric_limits::max()); response( 0, params->owner,