Skip to content

Commit

Permalink
FIX: ATRONIX: Always send a Error event in case of error
Browse files Browse the repository at this point in the history
Returning DR_ERROR is not enough, because that is not passed to user
script. User script depends on the ERROR event to detect errors.

(cherry picked from commit 245ca69)
  • Loading branch information
Oldes committed Nov 27, 2018
1 parent 16ae588 commit 4918d8a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/os/dev-net.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ static REBOOL Nonblocking_Mode(SOCKET sock)
***********************************************************************/
{
int type;
int protocol;
int protocol;
long result;

sock->error = 0;
Expand All @@ -210,6 +210,7 @@ static REBOOL Nonblocking_Mode(SOCKET sock)
// Failed, get error code (os local):
if (result == BAD_SOCKET) {
sock->error = GET_ERROR;
Signal_Device(sock, EVT_ERROR);
return DR_ERROR;
}

Expand All @@ -219,6 +220,7 @@ static REBOOL Nonblocking_Mode(SOCKET sock)
// Set socket to non-blocking async mode:
if (!Nonblocking_Mode(sock->socket)) {
sock->error = GET_ERROR;
Signal_Device(sock, EVT_ERROR);
return DR_ERROR;
}

Expand Down Expand Up @@ -262,6 +264,7 @@ static REBOOL Nonblocking_Mode(SOCKET sock)

if (CLOSE_SOCKET(sock->socket)) {
sock->error = GET_ERROR;
Signal_Device(sock, EVT_ERROR);
return DR_ERROR;
}
}
Expand Down Expand Up @@ -331,7 +334,7 @@ static REBOOL Nonblocking_Mode(SOCKET sock)
#endif

sock->error = GET_ERROR;
//Signal_Device(sock, EVT_ERROR);
Signal_Device(sock, EVT_ERROR);
return DR_ERROR; // Remove it from pending list
}

Expand Down Expand Up @@ -405,7 +408,7 @@ static REBOOL Nonblocking_Mode(SOCKET sock)
// An error happened:
CLR_FLAG(sock->state, RSM_ATTEMPT);
sock->error = result;
//Signal_Device(sock, EVT_ERROR);
Signal_Device(sock, EVT_ERROR);
return DR_ERROR;
}
}
Expand Down Expand Up @@ -446,6 +449,7 @@ static REBOOL Nonblocking_Mode(SOCKET sock)
if (!GET_FLAG(sock->state, RSM_CONNECT)
&& !GET_FLAG(sock->modes, RST_UDP)) {
sock->error = -18;
Signal_Device(sock, EVT_ERROR);
return DR_ERROR;
}

Expand Down Expand Up @@ -509,7 +513,7 @@ static REBOOL Nonblocking_Mode(SOCKET sock)
WATCH4("ERROR: recv(%d %x) len: %d error: %d\n", sock->socket, sock->data, len, result);
// A nasty error happened:
sock->error = result;
//Signal_Device(sock, EVT_ERROR);
Signal_Device(sock, EVT_ERROR);
return DR_ERROR;
}

Expand Down Expand Up @@ -540,6 +544,7 @@ static REBOOL Nonblocking_Mode(SOCKET sock)
if (result) {
lserr:
sock->error = GET_ERROR;
Signal_Device(sock, EVT_ERROR);
return DR_ERROR;
}

Expand Down Expand Up @@ -594,7 +599,7 @@ static REBOOL Nonblocking_Mode(SOCKET sock)
result = GET_ERROR;
if (result == NE_WOULDBLOCK) return DR_PEND;
sock->error = result;
//Signal_Device(sock, EVT_ERROR);
Signal_Device(sock, EVT_ERROR);
return DR_ERROR;
}

Expand Down

0 comments on commit 4918d8a

Please sign in to comment.