mirror of
https://github.com/espressif/esp-idf.git
synced 2026-05-28 16:46:31 +03:00
httpd_stop() and httpd_req_async_handler_complete() both pushed messages onto the control mbox via cs_send_to_ctrl_sock() without reserving a slot in ctrl_sock_semaphore. Once the silent-drop fix made the semaphore unconditional, the bypass became a real bug: when the mbox is saturated by pending httpd_queue_work() items the unguarded sendto() can return ENOBUFS, and even when it succeeds it leaves the semaphore overstating free slots until the consumer drains the message — a window during which a concurrent httpd_queue_work() can take a slot but still find the mbox full. Acquire the semaphore (portMAX_DELAY) before both sends and give it back on send failure so the take/give invariant is preserved. The httpd task is the consumer in both paths, so blocking is bounded and deadlock-free. Reword the stale "no-op give on full" comment in httpd_process_ctrl_msg() to reflect that only the recv-error path relies on the cap behavior now.