Skip to content

Commit

Permalink
[649] Don't close socket again if nonblock fails.
Browse files Browse the repository at this point in the history
Thanks to Edwin van den Oetelaar.

Bug: #649
  • Loading branch information
ralight committed Dec 21, 2017
1 parent ae666b0 commit b193918
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
1 change: 1 addition & 0 deletions ChangeLog.txt
Expand Up @@ -14,6 +14,7 @@ Client library:
- Fix incorrect PSK key being used if it had leading zeroes.
- Initialise "result" variable as soon as possible in
mosquitto_topic_matches_sub. Closes #654.
- No need to close socket again if setting non-blocking failed. Closes #649.

Build:
- Don't run TLS-PSK tests if TLS-PSK disabled at compile time. Closes #636.
Expand Down
8 changes: 0 additions & 8 deletions lib/net_mosq.c
Expand Up @@ -329,7 +329,6 @@ int _mosquitto_try_connect_step2(struct mosquitto *mosq, uint16_t port, mosq_soc

/* Set non-blocking */
if(_mosquitto_socket_nonblock(*sock)){
COMPAT_CLOSE(*sock);
continue;
}

Expand All @@ -344,7 +343,6 @@ int _mosquitto_try_connect_step2(struct mosquitto *mosq, uint16_t port, mosq_soc

/* Set non-blocking */
if(_mosquitto_socket_nonblock(*sock)){
COMPAT_CLOSE(*sock);
continue;
}
break;
Expand Down Expand Up @@ -429,7 +427,6 @@ int _mosquitto_try_connect(struct mosquitto *mosq, const char *host, uint16_t po
if(!blocking){
/* Set non-blocking */
if(_mosquitto_socket_nonblock(*sock)){
COMPAT_CLOSE(*sock);
continue;
}
}
Expand All @@ -446,7 +443,6 @@ int _mosquitto_try_connect(struct mosquitto *mosq, const char *host, uint16_t po
if(blocking){
/* Set non-blocking */
if(_mosquitto_socket_nonblock(*sock)){
COMPAT_CLOSE(*sock);
continue;
}
}
Expand Down Expand Up @@ -1250,7 +1246,6 @@ int _mosquitto_socketpair(mosq_sock_t *pairR, mosq_sock_t *pairW)
continue;
}
if(_mosquitto_socket_nonblock(spR)){
COMPAT_CLOSE(spR);
COMPAT_CLOSE(listensock);
continue;
}
Expand Down Expand Up @@ -1278,7 +1273,6 @@ int _mosquitto_socketpair(mosq_sock_t *pairR, mosq_sock_t *pairW)

if(_mosquitto_socket_nonblock(spW)){
COMPAT_CLOSE(spR);
COMPAT_CLOSE(spW);
COMPAT_CLOSE(listensock);
continue;
}
Expand All @@ -1296,13 +1290,11 @@ int _mosquitto_socketpair(mosq_sock_t *pairR, mosq_sock_t *pairW)
return MOSQ_ERR_ERRNO;
}
if(_mosquitto_socket_nonblock(sv[0])){
COMPAT_CLOSE(sv[0]);
COMPAT_CLOSE(sv[1]);
return MOSQ_ERR_ERRNO;
}
if(_mosquitto_socket_nonblock(sv[1])){
COMPAT_CLOSE(sv[0]);
COMPAT_CLOSE(sv[1]);
return MOSQ_ERR_ERRNO;
}
*pairR = sv[0];
Expand Down

0 comments on commit b193918

Please sign in to comment.