esphome / ESPAsyncWebServer

Async Web Server for ESP8266 and ESP32
81 stars 62 forks source link

Guard against concurrent access of the queues when using multiple tasks #26

Closed mathieucarbou closed 8 months ago

mathieucarbou commented 8 months ago

I currently have some random crashes due to the fact that the queues in the WS implementation are accessed from different RTOS tasks. I've placed some locks today, now trying to run it for a while to see if it crashed again in the queue loop. So far, a few hours without crash. I am pushing 1 or 2 ws events each second and the app can also react based on incoming ws events. This seems to work but I am not sure if there is a more efficient way to fix that.

I've opened this PR as draft because I'd like to test it for a few days.

Code inspired by:

mathieucarbou commented 8 months ago

good news, no crash during all night! I will continue testing for longer time. I usually got a crash per hour caused by these concurrent access.