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;