Commit e55c803
committed
net: lib: mqtt_client: Don't initialize MQTT client struct on connect
Part of the MQTT client struct initialization is memset() on the
structure and mutex initialization. Having this as a part of the
client connect doesn't work well in multi-threaded environment
(as in MQTT sample), where client reconnect can be triggered from
a different thread than regular client processing. In such case,
the mutex structure could be reinitialized while already being in
use by the MQTT helper thread, leading to asserts.
Fix this by initializing the MQTT client structure once, on MQTT
helper library init.
Align the mqtt_helper testsuite with the change.
Jira: NCSIDB-1569
Signed-off-by: Robert Lubos <[email protected]>1 parent 2b21d5a commit e55c803
File tree
2 files changed
+4
-6
lines changed- subsys/net/lib/mqtt_helper
- tests/subsys/net/lib/mqtt_helper/src
2 files changed
+4
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
452 | 452 | | |
453 | 453 | | |
454 | 454 | | |
455 | | - | |
456 | | - | |
457 | 455 | | |
458 | 456 | | |
459 | 457 | | |
| |||
576 | 574 | | |
577 | 575 | | |
578 | 576 | | |
| 577 | + | |
| 578 | + | |
579 | 579 | | |
580 | 580 | | |
581 | 581 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
| 245 | + | |
| 246 | + | |
245 | 247 | | |
246 | 248 | | |
247 | 249 | | |
| |||
272 | 274 | | |
273 | 275 | | |
274 | 276 | | |
275 | | - | |
276 | | - | |
277 | 277 | | |
278 | 278 | | |
279 | 279 | | |
| |||
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
302 | | - | |
303 | | - | |
304 | 302 | | |
305 | 303 | | |
306 | 304 | | |
| |||
0 commit comments