diff --git a/src/remote/inet.cpp b/src/remote/inet.cpp index 0cc6d354da..c08d1e5bee 100644 --- a/src/remote/inet.cpp +++ b/src/remote/inet.cpp @@ -1627,7 +1627,7 @@ static THREAD_ENTRY_DECLARE waitThread(THREAD_ENTRY_PARAM) } #endif // !defined(WIN_NT) -static void disconnect(rem_port* const port) +static void disconnect(rem_port* port) { /************************************** * @@ -1982,7 +1982,7 @@ static bool select_multi(rem_port* main_port, UCHAR* buffer, SSHORT bufsize, SSH { if (INET_shutting_down) { - if (main_port->port_state != rem_port::BROKEN) + if (main_port->port_state == rem_port::PENDING) { main_port->port_state = rem_port::BROKEN; @@ -2539,7 +2539,7 @@ static void inet_error(bool releasePort, rem_port* port, const TEXT* function, I **************************************/ if (status) { - if (port->port_state != rem_port::BROKEN) + if (port->port_state == rem_port::PENDING) { string err; err.printf("INET/inet_error: %s errno = %d", function, status); diff --git a/src/remote/os/win32/wnet.cpp b/src/remote/os/win32/wnet.cpp index 0b4bbcff01..d28500cae9 100644 --- a/src/remote/os/win32/wnet.cpp +++ b/src/remote/os/win32/wnet.cpp @@ -725,6 +725,11 @@ static void disconnect(rem_port* port) * **************************************/ + if (port->port_state == rem_port::DISCONNECTED) + return; + + port->port_state = rem_port::DISCONNECTED; + if (port->port_async) { disconnect(port->port_async); @@ -995,7 +1000,8 @@ static bool wnet_error(rem_port* port, **************************************/ if (status) { - if (port->port_state != rem_port::BROKEN) { + if (port->port_state == rem_port::PENDING) + { gds__log("WNET/wnet_error: %s errno = %d", function, status); } diff --git a/src/remote/os/win32/xnet.cpp b/src/remote/os/win32/xnet.cpp index 85ac3c7f8f..bb639d5fd9 100644 --- a/src/remote/os/win32/xnet.cpp +++ b/src/remote/os/win32/xnet.cpp @@ -1481,6 +1481,11 @@ static void disconnect(rem_port* port) * **************************************/ + if (port->port_state == rem_port::DISCONNECTED) + return; + + port->port_state = rem_port::DISCONNECTED; + if (port->port_async) { disconnect(port->port_async); @@ -1750,7 +1755,7 @@ static void xnet_error(rem_port* port, ISC_STATUS operation, int status) **************************************/ if (status) { - if (port->port_state != rem_port::BROKEN) + if (port->port_state == rem_port::PENDING) { gds__log("XNET/xnet_error: errno = %d", status); }