From: Flole998 Date: Thu, 27 Oct 2022 00:37:00 +0000 (+0200) Subject: Attempt to fix profile sharer memory leak X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc3759a58dd9dc914166262c8b59c2d4f0ed3f53;p=thirdparty%2Ftvheadend.git Attempt to fix profile sharer memory leak May or may not works, let's see.... --- diff --git a/src/profile.c b/src/profile.c index aa8aef961..554fb0235 100644 --- a/src/profile.c +++ b/src/profile.c @@ -955,27 +955,24 @@ profile_sharer_destroy(profile_chain_t *prch) { profile_sharer_t *prsh = prch->prch_sharer; profile_sharer_message_t *psm, *psm2; - int run = 0; if (prsh == NULL) return; - tvh_mutex_lock(&prsh->prsh_queue_mutex); LIST_REMOVE(prch, prch_sharer_link); if (LIST_EMPTY(&prsh->prsh_chains)) { - if ((run = prsh->prsh_queue_run) != 0) { + if (prsh->prsh_queue_run) { + tvh_mutex_lock(&prsh->prsh_queue_mutex); prsh->prsh_queue_run = 0; tvh_cond_signal(&prsh->prsh_queue_cond, 0); - } - prch->prch_sharer = NULL; - prch->prch_post_share = NULL; - } - tvh_mutex_unlock(&prsh->prsh_queue_mutex); - if (run) { - pthread_join(prsh->prsh_queue_thread, NULL); - while ((psm = TAILQ_FIRST(&prsh->prsh_queue)) != NULL) { - streaming_msg_free(psm->psm_sm); - TAILQ_REMOVE(&prsh->prsh_queue, psm, psm_link); - free(psm); + prch->prch_sharer = NULL; + prch->prch_post_share = NULL; + tvh_mutex_unlock(&prsh->prsh_queue_mutex); + pthread_join(prsh->prsh_queue_thread, NULL); + while ((psm = TAILQ_FIRST(&prsh->prsh_queue)) != NULL) { + streaming_msg_free(psm->psm_sm); + TAILQ_REMOVE(&prsh->prsh_queue, psm, psm_link); + free(psm); + } } if (prsh->prsh_tsfix) tsfix_destroy(prsh->prsh_tsfix); @@ -1012,7 +1009,7 @@ profile_sharer_destroy(profile_chain_t *prch) if (prsh->prsh_master == prch) prsh->prsh_master = NULL; tvh_mutex_unlock(&prsh->prsh_queue_mutex); - } + } } }