|
* Fix MQTT client: reset use_tls flag in connection_end (TLS to plain reconnect)
_nxd_mqtt_client_secure_connect sets nxd_mqtt_client_use_tls = 1 before
delegating to _nxd_mqtt_client_connect, but the flag is never cleared
afterwards. A subsequent non-secure connect on the same client inherits
the stale flag, triggers nx_secure_tls_session_start on a plain TCP
socket, and returns NXD_MQTT_CONNECT_FAILURE (0x10005).
Clear the flag in _nxd_mqtt_client_connection_end, after the TCP socket
is disconnected and unbound: while the socket can still deliver data, a
late TLS record (e.g. the peer's close_notify) must keep failing through
the TLS receive path rather than being parsed as plaintext MQTT bytes.
Clearing the flag before the socket teardown would let such a record be
misread as a partial MQTT message and parked forever in
nxd_mqtt_client_processing_packet, leaking a packet (caught by
netx_mqtt_packet_leak_test).
* Clean nxd_mqtt_client_use_tls on connect failure
* Complete the caller list of _nxd_mqtt_client_connection_end
* Add a regression test for a plain connection after a secure one
---------
Co-authored-by: Claude Fable 5 <[email protected]>
|