8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 21:23:04 +01:00

Fixed usage of rem_port states.

Fixed potential crash in wnet\xnet code (see fix for CORE-5863).
This commit is contained in:
hvlad 2018-07-01 18:09:53 +03:00
parent bdb7942a52
commit ca0c2823c3
3 changed files with 16 additions and 5 deletions

View File

@ -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);

View File

@ -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);
}

View File

@ -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);
}