mirror of
https://github.com/eclipse-mosquitto/mosquitto.git
synced 2026-09-25 19:34:16 +08:00
Add clients to session expiry check list when restarting and reloading from persistence.
Closes #2546. Thanks to Joachim Schachermayer.
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
1.6.16 - 2022-xx-xx
|
||||
===================
|
||||
|
||||
Broker:
|
||||
- Add clients to session expiry check list when restarting and reloading from
|
||||
persistence. Closes #2546.
|
||||
|
||||
|
||||
1.6.15 - 2021-06-08
|
||||
===================
|
||||
|
||||
|
||||
@@ -713,6 +713,7 @@ int mosquitto_security_auth_continue(struct mosquitto_db *db, struct mosquitto *
|
||||
* Session expiry
|
||||
* ============================================================ */
|
||||
int session_expiry__add(struct mosquitto_db *db, struct mosquitto *context);
|
||||
int session_expiry__add_from_persistence(struct mosquitto_db *db, struct mosquitto *context, time_t expiry_time);
|
||||
void session_expiry__remove(struct mosquitto *context);
|
||||
void session_expiry__remove_all(struct mosquitto_db *db);
|
||||
void session_expiry__check(struct mosquitto_db *db, time_t now);
|
||||
|
||||
+1
-1
@@ -209,7 +209,7 @@ static int persist__client_chunk_restore(struct mosquitto_db *db, FILE *db_fptr)
|
||||
}
|
||||
}
|
||||
}
|
||||
/* FIXME - we should expire clients here if they have exceeded their time */
|
||||
session_expiry__add_from_persistence(db, context, chunk.F.session_expiry_time);
|
||||
}else{
|
||||
rc = 1;
|
||||
}
|
||||
|
||||
@@ -80,6 +80,24 @@ int session_expiry__add(struct mosquitto_db *db, struct mosquitto *context)
|
||||
}
|
||||
|
||||
|
||||
int session_expiry__add_from_persistence(struct mosquitto_db *db, struct mosquitto *context, time_t expiry_time)
|
||||
{
|
||||
struct session_expiry_list *item;
|
||||
|
||||
item = mosquitto__calloc(1, sizeof(struct session_expiry_list));
|
||||
if(!item) return MOSQ_ERR_NOMEM;
|
||||
|
||||
item->context = context;
|
||||
item->context->session_expiry_time = expiry_time;
|
||||
|
||||
context->expiry_list_item = item;
|
||||
|
||||
DL_INSERT_INORDER(expiry_list, item, session_expiry__cmp);
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void session_expiry__remove(struct mosquitto *context)
|
||||
{
|
||||
if(context->expiry_list_item){
|
||||
|
||||
Reference in New Issue
Block a user