Stop listeners before removing clients to avoid use after free.

This commit is contained in:
Roger A. Light 2020-12-02 09:41:12 +00:00
parent 232a759320
commit 9e6efd2f32

View File

@ -541,14 +541,15 @@ int main(int argc, char *argv[])
#endif
session_expiry__remove_all();
listeners__stop(listensock, listensock_count);
HASH_ITER(hh_id, db.contexts_by_id, ctxt, ctxt_tmp){
#ifdef WITH_WEBSOCKETS
if(!ctxt->wsi){
if(!ctxt->wsi)
#endif
{
context__cleanup(ctxt, true);
}
#else
context__cleanup(ctxt, true);
#endif
}
HASH_ITER(hh_sock, db.contexts_by_sock, ctxt, ctxt_tmp){
context__cleanup(ctxt, true);
@ -565,8 +566,6 @@ int main(int argc, char *argv[])
db__close();
listeners__stop(listensock, listensock_count);
mosquitto_security_module_cleanup();
if(config.pid_file){