From 44302288552064d0325e2f54debca57710bad0f7 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Tue, 3 Jun 2014 16:21:46 +0100 Subject: [PATCH] Be consistent about removing listener counts on socket close. --- lib/net_mosq.c | 8 ++++++++ src/context.c | 10 ---------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/net_mosq.c b/lib/net_mosq.c index e04a514b..94d79860 100644 --- a/lib/net_mosq.c +++ b/lib/net_mosq.c @@ -215,6 +215,14 @@ int _mosquitto_socket_close(struct mosquitto *mosq) mosq->sock = INVALID_SOCKET; } +#ifdef WITH_BROKER + if(mosq->listener){ + mosq->listener->client_count--; + assert(mosq->listener->client_count >= 0); + mosq->listener = NULL; + } +#endif + return rc; } diff --git a/src/context.c b/src/context.c index b3c59954..821c55c4 100644 --- a/src/context.c +++ b/src/context.c @@ -118,12 +118,7 @@ void mqtt3_context_cleanup(struct mosquitto_db *db, struct mosquitto *context, b } #endif if(context->sock != -1){ - if(context->listener){ - context->listener->client_count--; - assert(context->listener->client_count >= 0); - } _mosquitto_socket_close(context); - context->listener = NULL; } if(context->clean_session && db){ mqtt3_subs_clean_session(db, context, &db->subs); @@ -192,11 +187,6 @@ void mqtt3_context_disconnect(struct mosquitto_db *db, struct mosquitto *ctxt) _mosquitto_free(ctxt->will); ctxt->will = NULL; } - if(ctxt->listener){ - ctxt->listener->client_count--; - assert(ctxt->listener->client_count >= 0); - ctxt->listener = NULL; - } ctxt->disconnect_t = mosquitto_time(); #ifdef WITH_SYS_TREE db->connected_count--;