-
Notifications
You must be signed in to change notification settings - Fork 634
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
Fix OTA_Shutdown() not releasing resources #1923
base: main
Are you sure you want to change the base?
Conversation
Related to aws#1910 Modify `otaThread` function in `demos/ota/ota_demo_core_http/ota_demo_core_http.c` to release resources properly. * Add `pthread_detach(pthread_self());` to detach the thread. * Add `pthread_exit(NULL);` to exit the thread.
Hello @vishwamartur, |
@vishwamartur Please describe how you tested these changes? |
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.
Thank you @vishwamartur for this contribution.
I think there might be a race condition. What if detach is called before the line 2117 (pthread_join)? That will cause undefined behavior.
And I think when the thread exits, it automatically cleans the resources. We need not have to call kill - it is an extreme measure in my opinion.
Also, I am not sure why would we need both join and detach. Both of them are mutually exclusive.
Or maybe I failed to understand something. Can you please clarify?
Thank you for highlighting the potential issues with Since I’ll update the code to use only Thanks again for catching this! Best, |
Related to #1910
Modify
otaThread
function indemos/ota/ota_demo_core_http/ota_demo_core_http.c
to release resources properly.pthread_detach(pthread_self());
to detach the thread.pthread_exit(NULL);
to exit the thread.