Don't leak sockets.

pull/1203/head
Roger A. Light 7 years ago
parent 754ac55151
commit 08249313a4

@ -110,6 +110,7 @@ enum mosquitto_client_state {
mosq_cs_connecting = 16,
mosq_cs_duplicate = 17, /* client that has been taken over by another with the same id */
mosq_cs_disconnect_with_will = 18,
mosq_cs_disused = 19, /* client that has been added to the disused list to be freed */
};
enum mosquitto__protocol {

@ -251,19 +251,19 @@ void context__send_will(struct mosquitto_db *db, struct mosquitto *ctxt)
void context__disconnect(struct mosquitto_db *db, struct mosquitto *context)
{
context->disconnect_t = time(NULL);
net__socket_close(db, context);
if(context->session_expiry_interval == 0){
context__send_will(db, context);
context->disconnect_t = time(NULL);
net__socket_close(db, context);
#ifdef WITH_BRIDGE
if(!context->bridge)
#endif
{
if(context->will_delay_interval == 0){
/* This will be done later, after the will is published */
/* This will be done later, after the will is published for delay>0. */
context__add_to_disused(db, context);
if(context->id){
context__remove_from_by_id(db, context);
@ -280,6 +280,10 @@ void context__disconnect(struct mosquitto_db *db, struct mosquitto *context)
void context__add_to_disused(struct mosquitto_db *db, struct mosquitto *context)
{
if(context->state == mosq_cs_disused) return;
context->state = mosq_cs_disused;
if(db->ll_for_free){
context->for_free_next = db->ll_for_free;
db->ll_for_free = context;

Loading…
Cancel
Save