The background network thread started by mosquitto_loop_start() was not
being stopped before mosquitto_destroy(), which can cause a use-after-free
if the thread is still running when the mosquitto structure is freed.
The MQTT client ID was generated using sprintf with %ld and time(nullptr).
On platforms with 32-bit userland but 64-bit kernel (such as Raspberry Pi OS
and some custom Alpine Linux builds), time_t is a 64-bit long long but %ld
only reads 32 bits. Since the upper 32 bits of the current Unix timestamp
are zero, this always produces "MMDVMHost.0", causing client ID collisions
when multiple instances or restarts occur.
Replace time()-based client IDs with PID-based IDs using getpid(), which is
always a 32-bit value and unique per process. Platform-guarded for Windows
(_getpid) and POSIX (getpid).
CDStarControl::clock(),
CM17Control::clock(),
CNXDNControl::clock(),
CP25Control::clock(),
CYSFControl::clock():
- Leave ASAP when it's disabled.
CDMRSlot::enable(),
CDStarControl::enable(),
CM17Control::enable(),
CNXDNControl::enable(),
CP25Control::enable(),
CYSFControl::enable():
- Log a message when Controller get disabled while running, "<MODE>, RF user has timed out" or "<MODE>, network user has timed out", depending of the RF/Net state.
CMMDVMHost::run():
- After getting the modem data, don't handle it (read/write<Controler>, etc) if the given mode is not enabled.
MMDVMHost:
- Rename CMMDVMHost::processEnableCommand() to CMMDVMHost::enableModemMode().
- Add CMMDVMHost::enableMode() and CMMDVMHost::disableMode(), called now from CMMDVMHost::remoteControl(), which clarify the code.
- CMMDVMHost::remoteControl():
* Fix indentation,
* Simplify ENABLE_x/DISABLE_x cases code.
- CMMDVMHost::setMode():
* Enable pocsag network only if m_pocsagEnabled is true,
* Enable ax25 network only if m_ax25Enabled is true (not m_fmEnabled).