mirror of
https://github.com/eclipse-mosquitto/mosquitto.git
synced 2026-09-28 16:14:35 +08:00
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>
This commit is contained in:
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.");
|
||||
|
||||
Reference in New Issue
Block a user