Fix Will not being sent for Websockets clients.
Closes #1143. Thanks to salcedo.
This commit is contained in:
parent
ab8b57ff54
commit
d6a690aa8d
@ -32,6 +32,7 @@ Broker:
|
|||||||
#1131.
|
#1131.
|
||||||
- Allow broker to always restart on Windows when using `log_dest file`. Closes
|
- Allow broker to always restart on Windows when using `log_dest file`. Closes
|
||||||
#1080.
|
#1080.
|
||||||
|
- Fix Will not being sent for Websockets clients. Closes #1143.
|
||||||
|
|
||||||
Library:
|
Library:
|
||||||
- Fix TLS connections not working over SOCKS.
|
- Fix TLS connections not working over SOCKS.
|
||||||
|
@ -208,8 +208,7 @@ struct mosquitto {
|
|||||||
#endif
|
#endif
|
||||||
bool clean_session;
|
bool clean_session;
|
||||||
#ifdef WITH_BROKER
|
#ifdef WITH_BROKER
|
||||||
char *old_id; /* for when a duplicate client connects, but we still want to
|
bool removed_from_by_id; /* True if removed from by_id hash */
|
||||||
know what the id was */
|
|
||||||
bool is_dropping;
|
bool is_dropping;
|
||||||
bool is_bridge;
|
bool is_bridge;
|
||||||
struct mosquitto__bridge *bridge;
|
struct mosquitto__bridge *bridge;
|
||||||
|
@ -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
|
assert(db); /* db can only be NULL here if the client hasn't sent a
|
||||||
CONNECT and hence wouldn't have an id. */
|
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);
|
mosquitto__free(context->id);
|
||||||
context->id = NULL;
|
context->id = NULL;
|
||||||
}
|
}
|
||||||
if(context->old_id){
|
|
||||||
mosquitto__free(context->old_id);
|
|
||||||
context->old_id = NULL;
|
|
||||||
}
|
|
||||||
packet__cleanup(&(context->in_packet));
|
packet__cleanup(&(context->in_packet));
|
||||||
if(context->current_out_packet){
|
if(context->current_out_packet){
|
||||||
packet__cleanup(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;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
10
src/loop.c
10
src/loop.c
@ -644,19 +644,13 @@ void do_disconnect(struct mosquitto_db *db, struct mosquitto *context)
|
|||||||
context->sock = INVALID_SOCKET;
|
context->sock = INVALID_SOCKET;
|
||||||
context->pollfd_index = -1;
|
context->pollfd_index = -1;
|
||||||
}
|
}
|
||||||
if(context->id){
|
context__remove_from_by_id(db, context);
|
||||||
HASH_DELETE(hh_id, db->contexts_by_id, context);
|
|
||||||
context->old_id = context->id;
|
|
||||||
context->id = NULL;
|
|
||||||
}
|
|
||||||
}else
|
}else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if(db->config->connection_messages == true){
|
if(db->config->connection_messages == true){
|
||||||
if(context->id){
|
if(context->id){
|
||||||
id = context->id;
|
id = context->id;
|
||||||
}else if(context->old_id){
|
|
||||||
id = context->old_id;
|
|
||||||
}else{
|
}else{
|
||||||
id = "<unknown>";
|
id = "<unknown>";
|
||||||
}
|
}
|
||||||
@ -681,7 +675,7 @@ void do_disconnect(struct mosquitto_db *db, struct mosquitto *context)
|
|||||||
#endif
|
#endif
|
||||||
context__add_to_disused(db, context);
|
context__add_to_disused(db, context);
|
||||||
if(context->id){
|
if(context->id){
|
||||||
HASH_DELETE(hh_id, db->contexts_by_id, context);
|
context__remove_from_by_id(db, context);
|
||||||
mosquitto__free(context->id);
|
mosquitto__free(context->id);
|
||||||
context->id = NULL;
|
context->id = NULL;
|
||||||
}
|
}
|
||||||
|
@ -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__add_to_disused(struct mosquitto_db *db, struct mosquitto *context);
|
||||||
void context__free_disused(struct mosquitto_db *db);
|
void context__free_disused(struct mosquitto_db *db);
|
||||||
void context__send_will(struct mosquitto_db *db, struct mosquitto *context);
|
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
|
* Logging functions
|
||||||
|
Loading…
Reference in New Issue
Block a user