]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Attempt to fix profile sharer memory leak
authorFlole998 <Flole998@users.noreply.github.com>
Thu, 27 Oct 2022 00:37:00 +0000 (02:37 +0200)
committerGitHub <noreply@github.com>
Thu, 27 Oct 2022 00:37:00 +0000 (02:37 +0200)
May or may not works, let's see....

src/profile.c

index aa8aef961af3e9562d5ee40b188725eb3b14e3f1..554fb0235083e3030f9462f429d48d6895c8ea56 100644 (file)
@@ -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);
-    }
+         } 
   }
 }