Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add semaphore xMqttMutex to protect mqtt->publish() and mqtt->loop() from conflicts with other concurrent threads #2024

Closed
wants to merge 0 commits into from

Conversation

puterboy
Copy link
Contributor

Description:

Protecting mqtt->publish() fixed the problem with corruption of MQTT discovery config messages #2012
Protecting mqtt->loop() seems like good practice since that could potentially conflict with another thread running mqtt->publish

Note I left mqtt->connect unprotected since I think that is unlikely to lead to data corruption or race conditions.
Similarly, I left mqtt->begin, mqtt->disconnect, mqtt->stop, mqtt->subscribe and mqtt->will unprotected since they occur either during setup or just prior to esp restart so I think again corruption and race conditions are unlikely.

Checklist:

  • [x ] The pull request is done against the latest development branch
  • Only one feature/fix was added per PR and the code change compiles without warnings
  • I accept the DCO.

@puterboy puterboy changed the title Add semaphore xMqttMutex to protect mqtt->publish() and mqtt->loop() from conflicts with other friends Add semaphore xMqttMutex to protect mqtt->publish() and mqtt->loop() from conflicts with other threads Aug 26, 2024
@puterboy puterboy changed the title Add semaphore xMqttMutex to protect mqtt->publish() and mqtt->loop() from conflicts with other threads Add semaphore xMqttMutex to protect mqtt->publish() and mqtt->loop() from conflicts with other concurrent threads Aug 26, 2024
@puterboy puterboy closed this Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant