mosquitto-lib: close socketpair on (re)connect

If the socket pair is still opened on reconnect, close it before
creating it again (just like the state variables). Otherwise, these
sockets are leaked on multiple mosquitto_connect() calls.

Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
pull/145/head
Simon Wunderlich 11 years ago committed by Roger A. Light
parent 720d52d86e
commit c02cdbefdc

@ -407,6 +407,15 @@ static int _mosquitto_connect_init(struct mosquitto *mosq, const char *host, int
mosq->keepalive = keepalive;
if(mosq->sockpairR != INVALID_SOCKET){
COMPAT_CLOSE(mosq->sockpairR);
mosq->sockpairR = INVALID_SOCKET;
}
if(mosq->sockpairW != INVALID_SOCKET){
COMPAT_CLOSE(mosq->sockpairW);
mosq->sockpairW = INVALID_SOCKET;
}
if(_mosquitto_socketpair(&mosq->sockpairR, &mosq->sockpairW)){
_mosquitto_log_printf(mosq, MOSQ_LOG_WARNING,
"Warning: Unable to open socket pair, outgoing publish commands may be delayed.");

Loading…
Cancel
Save