-
On server shutdown and when taking over a session. On disconnect, wills are queued first, we wait for the queueing to be done, then initiate disconnect. When TCP buffers are full and fds are not reported by epoll, the thread loop still exits and clients are just closed on exit.
-
This fixes not handling the last packet(s) of a client that disconnects.
-
Because that's what's it is now. A lot of code can be refactored to get the settings from this now, but I'm not going to do that yet.
-
There was not really a benefit to the old method, and this prevents packet pile up and keeps the code cleaner.
-
One fix is client destruction happening on the correct thread (when kicking another one off with existing client ID). This caused deadlocks on the subscriptions lock during a race condition when doKeepAliveCheck() also ran. A related deadlock was that the queued functions were executed while holding the lock taskQueueMutex. Together with the subscriptions lock, that was executed in the $SYS topic function, this also caused deadlocks.