Fix Will not being sent for Websockets clients.

Closes #1143. Thanks to salcedo.
This commit is contained in:
Roger A. Light 2019-02-03 22:01:33 +00:00
parent ab8b57ff54
commit d6a690aa8d
5 changed files with 14 additions and 15 deletions

View File

@ -32,6 +32,7 @@ Broker:
#1131.
- Allow broker to always restart on Windows when using `log_dest file`. Closes
#1080.
- Fix Will not being sent for Websockets clients. Closes #1143.
Library:
- Fix TLS connections not working over SOCKS.

View File

@ -208,8 +208,7 @@ 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 removed_from_by_id; /* True if removed from by_id hash */
bool is_dropping;
bool is_bridge;
struct mosquitto__bridge *bridge;

View File

@ -157,14 +157,10 @@ void context__cleanup(struct mosquitto_db *db, struct mosquitto *context, bool d
assert(db); /* db can only be NULL here if the client hasn't sent a
CONNECT and hence wouldn't have an id. */
HASH_DELETE(hh_id, db->contexts_by_id, context);
context__remove_from_by_id(db, context);
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);
@ -260,3 +256,11 @@ void context__free_disused(struct mosquitto_db *db)
db->ll_for_free = NULL;
}
void context__remove_from_by_id(struct mosquitto_db *db, struct mosquitto *context)
{
if(context->removed_from_by_id == false && context->id){
HASH_DELETE(hh_id, db->contexts_by_id, context);
context->removed_from_by_id = true;
}
}

View File

@ -644,19 +644,13 @@ void do_disconnect(struct mosquitto_db *db, struct mosquitto *context)
context->sock = INVALID_SOCKET;
context->pollfd_index = -1;
}
if(context->id){
HASH_DELETE(hh_id, db->contexts_by_id, context);
context->old_id = context->id;
context->id = NULL;
}
context__remove_from_by_id(db, context);
}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>";
}
@ -681,7 +675,7 @@ void do_disconnect(struct mosquitto_db *db, struct mosquitto *context)
#endif
context__add_to_disused(db, context);
if(context->id){
HASH_DELETE(hh_id, db->contexts_by_id, context);
context__remove_from_by_id(db, context);
mosquitto__free(context->id);
context->id = NULL;
}

View File

@ -587,6 +587,7 @@ void context__disconnect(struct mosquitto_db *db, struct mosquitto *context);
void context__add_to_disused(struct mosquitto_db *db, struct mosquitto *context);
void context__free_disused(struct mosquitto_db *db);
void context__send_will(struct mosquitto_db *db, struct mosquitto *context);
void context__remove_from_by_id(struct mosquitto_db *db, struct mosquitto *context);
/* ============================================================
* Logging functions