Disconnect clients consistently.

pull/211/merge
Roger A. Light 11 years ago
parent 22094aa00d
commit bb1a69b7d7

@ -132,7 +132,7 @@ void mqtt3_context_cleanup(struct mosquitto_db *db, struct mosquitto *context, b
} }
#endif #endif
_mosquitto_socket_close(db, context); _mosquitto_socket_close(db, context);
if(context->clean_session && db){ if((do_free || context->clean_session) && db){
mqtt3_subs_clean_session(db, context, &db->subs); mqtt3_subs_clean_session(db, context, &db->subs);
mqtt3_db_messages_delete(context); mqtt3_db_messages_delete(context);
} }

@ -163,14 +163,14 @@ int mosquitto_main_loop(struct mosquitto_db *db, int *listensock, int listensock
context->pollfd_index = pollfd_index; context->pollfd_index = pollfd_index;
pollfd_index++; pollfd_index++;
}else{ }else{
mqtt3_context_disconnect(db, context); do_disconnect(db, context);
} }
}else{ }else{
if(db->config->connection_messages == true){ if(db->config->connection_messages == true){
_mosquitto_log_printf(NULL, MOSQ_LOG_NOTICE, "Client %s has exceeded timeout, disconnecting.", context->id); _mosquitto_log_printf(NULL, MOSQ_LOG_NOTICE, "Client %s has exceeded timeout, disconnecting.", context->id);
} }
/* Client has exceeded keepalive*1.5 */ /* Client has exceeded keepalive*1.5 */
mqtt3_context_disconnect(db, context); do_disconnect(db, context);
} }
} }
} }

@ -648,7 +648,7 @@ int mqtt3_handle_disconnect(struct mosquitto_db *db, struct mosquitto *context)
_mosquitto_log_printf(NULL, MOSQ_LOG_DEBUG, "Received DISCONNECT from %s", context->id); _mosquitto_log_printf(NULL, MOSQ_LOG_DEBUG, "Received DISCONNECT from %s", context->id);
if(context->protocol == mosq_p_mqtt311){ if(context->protocol == mosq_p_mqtt311){
if((context->in_packet.command&0x0F) != 0x00){ if((context->in_packet.command&0x0F) != 0x00){
mqtt3_context_disconnect(db, context); do_disconnect(db, context);
return MOSQ_ERR_PROTOCOL; return MOSQ_ERR_PROTOCOL;
} }
} }

@ -194,6 +194,9 @@ int mosquitto_security_cleanup(struct mosquitto_db *db, bool reload)
int mosquitto_acl_check(struct mosquitto_db *db, struct mosquitto *context, const char *topic, int access) int mosquitto_acl_check(struct mosquitto_db *db, struct mosquitto *context, const char *topic, int access)
{ {
if(!context->id){
return MOSQ_ERR_ACL_DENIED;
}
if(!db->auth_plugin.lib){ if(!db->auth_plugin.lib){
return mosquitto_acl_check_default(db, context, topic, access); return mosquitto_acl_check_default(db, context, topic, access);
}else{ }else{

@ -703,13 +703,13 @@ int mosquitto_security_apply_default(struct mosquitto_db *db)
/* Check for anonymous clients when allow_anonymous is false */ /* Check for anonymous clients when allow_anonymous is false */
if(!allow_anonymous && !context->username){ if(!allow_anonymous && !context->username){
context->state = mosq_cs_disconnecting; context->state = mosq_cs_disconnecting;
_mosquitto_socket_close(db, context); do_disconnect(db, context);
continue; continue;
} }
/* Check for connected clients that are no longer authorised */ /* Check for connected clients that are no longer authorised */
if(mosquitto_unpwd_check_default(db, context->username, context->password) != MOSQ_ERR_SUCCESS){ if(mosquitto_unpwd_check_default(db, context->username, context->password) != MOSQ_ERR_SUCCESS){
context->state = mosq_cs_disconnecting; context->state = mosq_cs_disconnecting;
_mosquitto_socket_close(db, context); do_disconnect(db, context);
continue; continue;
} }
/* Check for ACLs and apply to user. */ /* Check for ACLs and apply to user. */

Loading…
Cancel
Save