Skip to content
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

OTA_Shutdown() not releasing resources #1910

Open
coratron opened this issue May 19, 2024 · 4 comments
Open

OTA_Shutdown() not releasing resources #1910

coratron opened this issue May 19, 2024 · 4 comments

Comments

@coratron
Copy link

coratron commented May 19, 2024

I am using the following:

The problem:

The OTA task consumes about 10kB of RAM. Calling OTA_Shutdown() should release the resources but it is not.

Confirmed with logs by checking the RAM before and after, as well as verbose logging which ends in
I (100117) AWS_OTA: OTA Agent stopped.

I am basing my code on the OTA example. In other words, the result should be reproducible by measuring the RAM watermark before aws_iot_ota() and at the end of it.

@coratron
Copy link
Author

Leaving this here until someone has a look:

I have solved the issue and recommend modifying the otaThread function in the example to:

void* otaThread(void* pParam)
{
    /* Calling OTA agent task. */
    OTA_EventProcessingTask(pParam);
    LogInfo(("OTA Agent stopped."));

    pthread_detach(pthread_self());
    pthread_exit(NULL);

    return NULL;
}

Otherwise the resources allocated to the thread will not be released.

@coratron
Copy link
Author

Restarting OTA is the next issue after releasing the resources : the system gets caught here on the second start up pass:

  else
        {
            /* Drop all events that created after OTA_Shutdown. */
            resetEventQueue();
        }

in OTA_Init

@paulbartell
Copy link
Member

@coratron Thanks for the bug report. Would you mind opening a Pull Request with your suggested fix?

vishwamartur added a commit to vishwamartur/aws-iot-device-sdk-embedded-C that referenced this issue Oct 30, 2024
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.
@ActoryOu
Copy link
Member

ActoryOu commented Nov 2, 2024

Hi @coratron,
Could you help take a look on #1923 to check if this is the patch you want?

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants