-
Notifications
You must be signed in to change notification settings - Fork 1.5k
ESP32/ESP32-C3: Fix leak of semaphores created by Wi-Fi kernel thread #6322
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
ESP32/ESP32-C3: Fix leak of semaphores created by Wi-Fi kernel thread #6322
Conversation
This reverts commit f5eaf82. Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
pkarashchenko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
|
One question from my side. Do we expect multi-instance of wifi driver? If not, then maybe we can just have a global semaphore pointer and use that on/atexit? |
The Wi-Fi library creates a new semaphore for every thread that performs connection operations, so we cannot have a global pointer. But on NuttX it resulted in the semaphores not being destroyed. I'll try to explain why. So the catch here is that NuttX provides this process-like abstraction which segregates pthreads created from different tasks. So a pthread created from Task B won't be able to share keys of type |
No, the Wi-Fi driver does not expect to be initialized more than once. |
|
my config had TLS_TASK_NELEM=0 and i got a bit surprised by this change breaking the build. |
|
Task tls is disabled by default.:( |
Yes. I just reexamined the task tls code and see that I did a wrong assumption. |
Summary
This PR intends to provide an alternative solution to the fix provide on #4092 for ESP32-C3, and extend it to the ESP32 Wi-Fi driver.
Originally, the semaphores created by the Wi-Fi kernel thread for handling application connection requests were not being destroyed, causing the a memory leak of 32 bytes for every
wapiinvocation.The ESP32-C3 solution is being refactored in order to avoid the usage of
on_exitin driver code, see: #6197Impact
Fix for semaphore leak on ESP32 and refactor of current solution on ESP32-C3.
Testing
esp32-devkitc:wapiesp32c3-devkit:wapi