Fix client id not showing in log on failed connections, where possible.
This commit is contained in:
parent
3b471c8669
commit
be80a3f4d0
@ -9,6 +9,7 @@ Broker:
|
|||||||
- Fix problem parsing config files with Windows line endings. Closes #2297.
|
- Fix problem parsing config files with Windows line endings. Closes #2297.
|
||||||
- Don't send retained messages when a shared subscription is made.
|
- Don't send retained messages when a shared subscription is made.
|
||||||
- Fix log being truncated in Windows.
|
- Fix log being truncated in Windows.
|
||||||
|
- Fix client id not showing in log on failed connections, where possible.
|
||||||
|
|
||||||
Client library:
|
Client library:
|
||||||
- Initialise sockpairR/W to invalid in `mosquitto_reinitialise()` to avoid
|
- Initialise sockpairR/W to invalid in `mosquitto_reinitialise()` to avoid
|
||||||
|
@ -17,6 +17,11 @@ struct mosquitto *context__init(mosq_sock_t sock)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void context__add_to_by_id(struct mosquitto *context)
|
||||||
|
{
|
||||||
|
UNUSED(context);
|
||||||
|
}
|
||||||
|
|
||||||
int db__message_store(const struct mosquitto *source, struct mosquitto_msg_store *stored, uint32_t message_expiry_interval, dbid_t store_id, enum mosquitto_msg_origin origin)
|
int db__message_store(const struct mosquitto *source, struct mosquitto_msg_store *stored, uint32_t message_expiry_interval, dbid_t store_id, enum mosquitto_msg_origin origin)
|
||||||
{
|
{
|
||||||
UNUSED(source);
|
UNUSED(source);
|
||||||
|
@ -285,7 +285,7 @@ struct mosquitto {
|
|||||||
time_t session_expiry_time;
|
time_t session_expiry_time;
|
||||||
uint32_t session_expiry_interval;
|
uint32_t session_expiry_interval;
|
||||||
#ifdef WITH_BROKER
|
#ifdef WITH_BROKER
|
||||||
bool removed_from_by_id; /* True if removed from by_id hash */
|
bool in_by_id;
|
||||||
bool is_dropping;
|
bool is_dropping;
|
||||||
bool is_bridge;
|
bool is_bridge;
|
||||||
struct mosquitto__bridge *bridge;
|
struct mosquitto__bridge *bridge;
|
||||||
|
@ -92,7 +92,7 @@ int bridge__new(struct mosquitto__bridge *bridge)
|
|||||||
return MOSQ_ERR_NOMEM;
|
return MOSQ_ERR_NOMEM;
|
||||||
}
|
}
|
||||||
new_context->id = local_id;
|
new_context->id = local_id;
|
||||||
HASH_ADD_KEYPTR(hh_id, db.contexts_by_id, new_context->id, strlen(new_context->id), new_context);
|
context__add_to_by_id(new_context);
|
||||||
}
|
}
|
||||||
new_context->bridge = bridge;
|
new_context->bridge = bridge;
|
||||||
new_context->is_bridge = true;
|
new_context->is_bridge = true;
|
||||||
|
@ -281,16 +281,25 @@ void context__free_disused(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void context__add_to_by_id(struct mosquitto *context)
|
||||||
|
{
|
||||||
|
if(context->in_by_id == false){
|
||||||
|
context->in_by_id = true;
|
||||||
|
HASH_ADD_KEYPTR(hh_id, db.contexts_by_id, context->id, strlen(context->id), context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void context__remove_from_by_id(struct mosquitto *context)
|
void context__remove_from_by_id(struct mosquitto *context)
|
||||||
{
|
{
|
||||||
struct mosquitto *context_found;
|
struct mosquitto *context_found;
|
||||||
|
|
||||||
if(context->removed_from_by_id == false && context->id){
|
if(context->in_by_id == true && context->id){
|
||||||
HASH_FIND(hh_id, db.contexts_by_id, context->id, strlen(context->id), context_found);
|
HASH_FIND(hh_id, db.contexts_by_id, context->id, strlen(context->id), context_found);
|
||||||
if(context_found){
|
if(context_found){
|
||||||
HASH_DELETE(hh_id, db.contexts_by_id, context_found);
|
HASH_DELETE(hh_id, db.contexts_by_id, context_found);
|
||||||
}
|
}
|
||||||
context->removed_from_by_id = true;
|
context->in_by_id = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ int connect__on_authorised(struct mosquitto *context, void *auth_data_out, uint1
|
|||||||
connection_check_acl(context, &context->msgs_out.inflight);
|
connection_check_acl(context, &context->msgs_out.inflight);
|
||||||
connection_check_acl(context, &context->msgs_out.queued);
|
connection_check_acl(context, &context->msgs_out.queued);
|
||||||
|
|
||||||
HASH_ADD_KEYPTR(hh_id, db.contexts_by_id, context->id, strlen(context->id), context);
|
context__add_to_by_id(context);
|
||||||
|
|
||||||
#ifdef WITH_PERSISTENCE
|
#ifdef WITH_PERSISTENCE
|
||||||
if(!context->clean_start){
|
if(!context->clean_start){
|
||||||
@ -908,12 +908,6 @@ int handle__connect(struct mosquitto *context)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
rc = mosquitto_unpwd_check(context);
|
rc = mosquitto_unpwd_check(context);
|
||||||
if(rc != MOSQ_ERR_SUCCESS){
|
|
||||||
/* We must have context->id == NULL here so we don't later try and
|
|
||||||
* remove the client from the by_id hash table */
|
|
||||||
mosquitto__free(context->id);
|
|
||||||
context->id = NULL;
|
|
||||||
}
|
|
||||||
switch(rc){
|
switch(rc){
|
||||||
case MOSQ_ERR_SUCCESS:
|
case MOSQ_ERR_SUCCESS:
|
||||||
break;
|
break;
|
||||||
|
@ -692,6 +692,7 @@ void context__disconnect(struct mosquitto *context);
|
|||||||
void context__add_to_disused(struct mosquitto *context);
|
void context__add_to_disused(struct mosquitto *context);
|
||||||
void context__free_disused(void);
|
void context__free_disused(void);
|
||||||
void context__send_will(struct mosquitto *context);
|
void context__send_will(struct mosquitto *context);
|
||||||
|
void context__add_to_by_id(struct mosquitto *context);
|
||||||
void context__remove_from_by_id(struct mosquitto *context);
|
void context__remove_from_by_id(struct mosquitto *context);
|
||||||
|
|
||||||
int connect__on_authorised(struct mosquitto *context, void *auth_data_out, uint16_t auth_data_out_len);
|
int connect__on_authorised(struct mosquitto *context, void *auth_data_out, uint16_t auth_data_out_len);
|
||||||
|
@ -64,7 +64,7 @@ static struct mosquitto *persist__find_or_add_context(const char *client_id, uin
|
|||||||
|
|
||||||
context->clean_start = false;
|
context->clean_start = false;
|
||||||
|
|
||||||
HASH_ADD_KEYPTR(hh_id, db.contexts_by_id, context->id, strlen(context->id), context);
|
context__add_to_by_id(context);
|
||||||
}
|
}
|
||||||
if(last_mid){
|
if(last_mid){
|
||||||
context->last_mid = last_mid;
|
context->last_mid = last_mid;
|
||||||
|
Loading…
Reference in New Issue
Block a user