mirror of
https://github.com/esphome/esphome.git
synced 2026-09-11 23:37:34 +00:00
f4a055f342435dfbba5913efad74bf408e36f1c8
AsyncEventSource::handleRequest() runs on the ESP-IDF httpd task. Prior to this change it mutated sessions_, event_buffer_, deferred_queue_, and entities_iterator_ directly: appending the new response to sessions_, sending the initial ping/config/sorting_groups through try_send_nodefer() (which writes event_buffer_), and calling entities_iterator_.begin(). The main loop reads/writes the same fields from WebServer::loop() on the main task, so every new SSE connect raced with any in-flight loop tick. The httpd path now only performs the HTTP-level setup that requires the live httpd_req_t (headers, initial chunk, sess_ctx/free_ctx, fd_, send override) and parks the response on pending_sessions_ under a mutex. The main loop checks a std::atomic<bool> fast-path gate per tick; when set it swaps the pending list out under the lock and then — outside the lock — pushes into sessions_, invokes on_connect_, and calls prime_() which performs the initial sends and starts entities_iterator_. sessions_, event_buffer_, deferred_queue_, and entities_iterator_ are now mutated exclusively from the main loop. fd_ remains the only cross-thread signal (std::atomic<int> cleared by destroy() on the httpd/tcpip task).
Description
ESPHome is a system to control your ESP8266/ESP32 by simple yet powerful configuration files and control them remotely through Home Automation systems.
Readme
Multiple Licenses
591 MiB
Languages
C++
55.8%
Python
43.6%
C
0.3%
JavaScript
0.2%
