mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
fix mem break when mqtt_thread not exit
This commit is contained in:
parent
d1499ff983
commit
1c55ca0223
@ -1612,7 +1612,12 @@ int mqtt_set_will_options(mqtt_client_t* c,
|
||||
}
|
||||
|
||||
int mqtt_release_free(mqtt_client_t* c) {
|
||||
mqtt_clean_session(c);
|
||||
/* wait for mqtt thread exit */
|
||||
while (c->mqtt_thread != NULL) {
|
||||
}
|
||||
if (CLIENT_STATE_INVALID != mqtt_get_client_state(c)) {
|
||||
mqtt_clean_session(c);
|
||||
}
|
||||
mqtt_release(c);
|
||||
platform_memory_free(c);
|
||||
return 0;
|
||||
|
@ -83,8 +83,11 @@ PIKA_WEAK void platform_thread_start(platform_thread_t* thread) {
|
||||
|
||||
PIKA_WEAK void platform_thread_destroy(platform_thread_t* thread) {
|
||||
#ifdef __linux
|
||||
if (NULL != thread)
|
||||
if (NULL != thread){
|
||||
pthread_detach(thread->thread);
|
||||
platform_memory_free(thread);
|
||||
thread = NULL;
|
||||
}
|
||||
#elif PIKA_FREERTOS_ENABLE
|
||||
if (NULL != thread)
|
||||
vTaskDelete(thread->thread);
|
||||
|
@ -1612,7 +1612,12 @@ int mqtt_set_will_options(mqtt_client_t* c,
|
||||
}
|
||||
|
||||
int mqtt_release_free(mqtt_client_t* c) {
|
||||
mqtt_clean_session(c);
|
||||
/* wait for mqtt thread exit */
|
||||
while (c->mqtt_thread != NULL) {
|
||||
}
|
||||
if (CLIENT_STATE_INVALID != mqtt_get_client_state(c)) {
|
||||
mqtt_clean_session(c);
|
||||
}
|
||||
mqtt_release(c);
|
||||
platform_memory_free(c);
|
||||
return 0;
|
||||
|
@ -83,8 +83,11 @@ PIKA_WEAK void platform_thread_start(platform_thread_t* thread) {
|
||||
|
||||
PIKA_WEAK void platform_thread_destroy(platform_thread_t* thread) {
|
||||
#ifdef __linux
|
||||
if (NULL != thread)
|
||||
if (NULL != thread){
|
||||
pthread_detach(thread->thread);
|
||||
platform_memory_free(thread);
|
||||
thread = NULL;
|
||||
}
|
||||
#elif PIKA_FREERTOS_ENABLE
|
||||
if (NULL != thread)
|
||||
vTaskDelete(thread->thread);
|
||||
|
Loading…
x
Reference in New Issue
Block a user