Skip to content

Commit

Permalink
Close socket on error in NetCOnnect
Browse files Browse the repository at this point in the history
  • Loading branch information
embhorn committed Nov 27, 2023
1 parent 53d541f commit f7f55d5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions examples/mqttnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ static int NetConnect(void *context, const char* host, word16 port,
if (errno == EINPROGRESS || errno == EWOULDBLOCK) {
return MQTT_CODE_CONTINUE;
}
SOCK_CLOSE(sock->fd);

/* Show error */
PRINTF("NetConnect: Rc=%d, ErrNo=%d", rc, errno);
Expand Down Expand Up @@ -540,7 +541,8 @@ static int NetConnect(void *context, const char* host, word16 port,

exit:
/* Show error */
if (rc != 0) {
if ((rc != 0) && (rc != MQTT_CODE_CONTINUE)) {
SOCK_CLOSE(sock->fd);
PRINTF("NetConnect: Rc=%d, SoErr=%d", rc, so_error);
}

Expand Down Expand Up @@ -630,7 +632,7 @@ static int SN_NetConnect(void *context, const char* host, word16 port,

exit:
/* Show error */
if (rc != 0) {
if ((rc != 0) && (rc != MQTT_CODE_CONTINUE)) {
SOCK_CLOSE(sock->fd);
PRINTF("NetConnect: Rc=%d, SoErr=%d", rc, so_error);
}
Expand Down

0 comments on commit f7f55d5

Please sign in to comment.