Skip to content

Commit beaa826

Browse files
committed
Bug#29431134: MASTER : HANG IN SESSION CREATION TN INVALID HOST ON WINDOWS
Fixing timeout logic once more. Since 0 means no timeout, we pass 1 (microsecond) in case there is no time left.
1 parent 1c0d4f1 commit beaa826

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

cdk/foundation/socket_detail.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ PUSH_SYS_WARNINGS_CDK
4444
#include <limits>
4545
#include <chrono>
4646
#include <sstream>
47+
4748
#ifndef _WIN32
4849
#include <arpa/inet.h>
4950
#include <signal.h>
@@ -613,7 +614,7 @@ Socket connect(const char *host_name, unsigned short port,
613614

614615
int select_result = poll_one(
615616
socket, POLL_MODE_CONNECT, true,
616-
timeout_usec > 0 && timeout > 0 ? timeout : 0
617+
0 == timeout_usec ? 0 : timeout > 0 ? timeout : 1
617618
);
618619

619620
if (select_result == 0 && (timeout_usec > 0) &&
@@ -764,6 +765,7 @@ Socket listen_and_accept(unsigned short port)
764765
return client;
765766
}
766767

768+
767769
int poll_one(Socket socket, Poll_mode mode, bool wait,
768770
uint64_t timeout_usec)
769771
{
@@ -796,7 +798,8 @@ DIAGNOSTIC_POP_CDK
796798

797799
//milliseconds
798800
int timeout =
799-
!wait ? 0 : timeout_usec > 0 ? static_cast<int>(timeout_usec / 1000) : -1;
801+
!wait ? 0
802+
: timeout_usec > 0 ? static_cast<int>((1000+timeout_usec) / 1000) : -1;
800803

801804
#ifdef _WIN32
802805
int result = ::WSAPoll(&fds, 1, timeout);

0 commit comments

Comments
 (0)