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

Improve jsonBufferLock management #4089

Merged
merged 3 commits into from
Aug 5, 2024

Conversation

willmmiles
Copy link
Collaborator

This patch set fixes some hangs and potential crashes with jsonBufferLock contention.

  • On ESP8266, avoid calling delay() in system context. This fixes some crashes if the lock is contended during web server callbacks. As it is not possible to wait in system context, immediately return failure.
  • On ESP32, use a recursive semaphore instead of a delay() loop. This improves overall performance as the CPU doesn't cycle needlessly, and fixes hanging up for the timeout interval in cases when the contention is from the same task, eg. two web requests.
  • Use DEBUG_PRINTF_P for the debug messages, a tiny code size savings.

On ESP8266, it isn't permissible to call delay() in system context;
ensure this is legal before waiting.

On ESP32, use an operating system mutex to ensure consistent variable
state in a multicore environment, and manage the wait without needing
to loop.
For debugging, also log who was trying to lock when it was contended.
Tiny code space usage reduction.
@blazoncek blazoncek merged commit 9d860c2 into Aircoookie:0_15 Aug 5, 2024
0 of 2 checks passed
softhack007 pushed a commit to MoonModules/WLED that referenced this pull request Aug 8, 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.

2 participants