mirror of
https://github.com/eclipse-mosquitto/mosquitto.git
synced 2026-09-20 14:57:34 +08:00
Fix incorrect hash usage with duplicate clients.
Fix duplicate clients being added to by_id hash before the old client was removed. Closes #645.
This commit is contained in:
@@ -7,6 +7,8 @@ Broker:
|
||||
- Fix retained messages not sent by bridges on outgoing topics at the first
|
||||
connection. Closes #701.
|
||||
- Minor documentation fixes. Closes #520.
|
||||
- Fix duplicate clients being added to by_id hash before the old client was
|
||||
removed. Closes #645.
|
||||
|
||||
Build:
|
||||
- Various fixes to ease building.
|
||||
|
||||
@@ -208,6 +208,8 @@ struct mosquitto {
|
||||
#endif
|
||||
bool clean_session;
|
||||
#ifdef WITH_BROKER
|
||||
char *old_id; /* for when a duplicate client connects, but we still want to
|
||||
know what the id was */
|
||||
bool is_dropping;
|
||||
bool is_bridge;
|
||||
struct mosquitto__bridge *bridge;
|
||||
|
||||
@@ -161,6 +161,10 @@ void context__cleanup(struct mosquitto_db *db, struct mosquitto *context, bool d
|
||||
mosquitto__free(context->id);
|
||||
context->id = NULL;
|
||||
}
|
||||
if(context->old_id){
|
||||
mosquitto__free(context->old_id);
|
||||
context->old_id = NULL;
|
||||
}
|
||||
packet__cleanup(&(context->in_packet));
|
||||
if(context->current_out_packet){
|
||||
packet__cleanup(context->current_out_packet);
|
||||
|
||||
@@ -638,12 +638,17 @@ void do_disconnect(struct mosquitto_db *db, struct mosquitto *context)
|
||||
context->sock = INVALID_SOCKET;
|
||||
context->pollfd_index = -1;
|
||||
}
|
||||
HASH_DELETE(hh_id, db->contexts_by_id, context);
|
||||
context->old_id = context->id;
|
||||
context->id = NULL;
|
||||
}else
|
||||
#endif
|
||||
{
|
||||
if(db->config->connection_messages == true){
|
||||
if(context->id){
|
||||
id = context->id;
|
||||
}else if(context->old_id){
|
||||
id = context->old_id;
|
||||
}else{
|
||||
id = "<unknown>";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user