From 482d604598078f7df34f891bf4dc50c1bf9018cb Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Mon, 23 Jun 2014 23:51:16 +0100 Subject: [PATCH] Only remove from hash if a valid socket (i.e. if present) --- src/read_handle_server.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/read_handle_server.c b/src/read_handle_server.c index e1a236e3..4b4516a7 100644 --- a/src/read_handle_server.c +++ b/src/read_handle_server.c @@ -425,7 +425,9 @@ int mqtt3_handle_connect(struct mosquitto_db *db, struct mosquitto *context) found_context->address = NULL; } found_context->disconnect_t = 0; - HASH_DELETE(hh_sock, db->contexts_by_sock, context); + if(context->sock != INVALID_SOCKET){ + HASH_DELETE(hh_sock, db->contexts_by_sock, context); + } found_context->sock = context->sock; found_context->listener = context->listener; context->listener = NULL;