Skip to content

Commit

Permalink
fix socket connect timeout after error
Browse files Browse the repository at this point in the history
  • Loading branch information
sniper00 committed Oct 1, 2024
1 parent 75cf4ce commit 2a090d4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions moon-src/core/network/socket_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -242,6 +242,8 @@ void socket_server::connect(
PTYPE_INTEGER
);
} else {
//Set the fd flag to prevent timeout handling
conn->fd(std::numeric_limits<uint32_t>::max());
response(
0,
params->owner,
Expand All @@ -259,6 +261,8 @@ void socket_server::connect(
}
);
} else {
//Set the fd flag to prevent timeout handling
conn->fd(std::numeric_limits<uint32_t>::max());
response(
0,
params->owner,
Expand Down

0 comments on commit 2a090d4

Please sign in to comment.