]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
satip server: fix memory leak for the slave service subscription, fixes #5314
authorJaroslav Kysela <perex@perex.cz>
Wed, 7 Nov 2018 15:10:06 +0000 (16:10 +0100)
committerJaroslav Kysela <perex@perex.cz>
Wed, 7 Nov 2018 16:17:35 +0000 (17:17 +0100)
src/dvr/dvr_rec.c
src/htsp_server.c
src/profile.c
src/profile.h
src/satip/rtsp.c
src/service_mapper.c
src/subscriptions.c
src/webui/webui.c

index 28a6f9fc102df84acd83b4e5f0f7e28be77a024b..a3291d6766a6202f667e640e8747d5cc0eb11b4c 100644 (file)
@@ -118,13 +118,13 @@ dvr_rec_subscribe(dvr_entry_t *de)
 
   pro = de->de_config->dvr_profile;
   prch = malloc(sizeof(*prch));
-  profile_chain_init(prch, pro, de->de_channel);
+  profile_chain_init(prch, pro, de->de_channel, 1);
   if (profile_chain_open(prch, &de->de_config->dvr_muxcnf, 0, 0)) {
     profile_chain_close(prch);
     tvherror(LS_DVR, "unable to create new channel streaming chain '%s' for '%s', using default",
              profile_get_name(pro), channel_get_name(de->de_channel));
     pro = profile_find_by_name(NULL, NULL);
-    profile_chain_init(prch, pro, de->de_channel);
+    profile_chain_init(prch, pro, de->de_channel, 1);
     if (profile_chain_open(prch, &de->de_config->dvr_muxcnf, 0, 0)) {
       tvherror(LS_DVR, "unable to create channel streaming default chain '%s' for '%s'",
                profile_get_name(pro), channel_get_name(de->de_channel));
index f349543e8ae9f46fe12c8d81f456949ed540be73..9ee8d01a9e1c1e35355b4c7466511692a1c1a224 100644 (file)
@@ -2490,7 +2490,7 @@ htsp_method_subscribe(htsp_connection_t *htsp, htsmsg_t *in)
 
   pro = profile_find_by_list(htsp->htsp_granted_access->aa_profiles, profile_id,
                              "htsp", SUBSCRIPTION_PACKET | SUBSCRIPTION_HTSP);
-  profile_chain_init(&hs->hs_prch, pro, ch);
+  profile_chain_init(&hs->hs_prch, pro, ch, 1);
   if (profile_chain_work(&hs->hs_prch, &hs->hs_input, timeshiftPeriod, 0)) {
     tvherror(LS_HTSP, "unable to create profile chain '%s'", profile_get_name(pro));
     profile_chain_close(&hs->hs_prch);
index a8006b7305d075e0c085e37e15f9415a427b0f18..05c181b894e70bb53523e79b73927fd912044a36 100644 (file)
@@ -866,15 +866,17 @@ profile_sharer_destroy(profile_chain_t *prch)
  *
  */
 void
-profile_chain_init(profile_chain_t *prch, profile_t *pro, void *id)
+profile_chain_init(profile_chain_t *prch, profile_t *pro, void *id, int queue)
 {
   memset(prch, 0, sizeof(*prch));
   if (pro)
     profile_grab(pro);
   prch->prch_pro = pro;
   prch->prch_id  = id;
-  streaming_queue_init(&prch->prch_sq, 0, 0);
-  prch->prch_sq_used = 1;
+  if (queue) {
+    streaming_queue_init(&prch->prch_sq, 0, 0);
+    prch->prch_sq_used = 1;
+  }
   LIST_INSERT_HEAD(&profile_chains, prch, prch_link);
   prch->prch_linked = 1;
   prch->prch_stop = 1;
index bcb8fd8dfd4fbb628371a7b96dd4929b3416c5fc..f4b795f545635ea6718ce4ab431bba25f7d5c219 100644 (file)
@@ -170,7 +170,7 @@ profile_chain_reopen(profile_chain_t *prch,
 int
 profile_chain_open(profile_chain_t *prch,
                    muxer_config_t *m_cfg, int flags, size_t qsize);
-void profile_chain_init(profile_chain_t *prch, profile_t *pro, void *id);
+void profile_chain_init(profile_chain_t *prch, profile_t *pro, void *id, int queue);
 int  profile_chain_raw_open(profile_chain_t *prch, void *id, size_t qsize, int muxer);
 void profile_chain_close(profile_chain_t *prch);
 int  profile_chain_weight(profile_chain_t *prch, int custom);
index 57a999ad67c55274fe43ec7f76f9a61795b1bc41..701dd9a2db81340aa8f6288c0e281bad3669d5cc 100644 (file)
@@ -332,9 +332,7 @@ rtsp_slave_add
   pthread_mutex_unlock(&master->s_stream_mutex);
   master->s_link(master, slave);
   sub->service = slave;
-  profile_chain_init(&sub->prch, NULL, NULL);
-  sub->prch.prch_st = &sub->prch.prch_sq.sq_st;
-  sub->prch.prch_id = slave;
+  profile_chain_init(&sub->prch, NULL, slave, 0);
   snprintf(buf, sizeof(buf), "SAT>IP Slave/%s", slave->s_nicename);
   sub->ths = subscription_create_from_service(&sub->prch, NULL,
                                               SUBSCRIPTION_NONE,
index 5267d3a94884827e95d55dc73d498e40675167a5..c445c1d8c2f8ff846f9577559a67f609d5deaee9 100644 (file)
@@ -303,7 +303,7 @@ service_mapper_thread ( void *aux )
   const char *err = NULL;
   uint64_t timeout;
 
-  profile_chain_init(&prch, NULL, NULL);
+  profile_chain_init(&prch, NULL, NULL, 1);
   prch.prch_st = &prch.prch_sq.sq_st;
   sq = &prch.prch_sq;
 
index f8c2a587cb228da5e93bd35be8aabda8807bbcc4..152e73db45e4fef0ec19f96c3c64ba2076568953 100644 (file)
@@ -909,7 +909,7 @@ subscription_create_from_channel(profile_chain_t *prch,
                                 const char *client,
                                 int *error)
 {
-  assert(prch->prch_st);
+  assert(flags == SUBSCRIPTION_NONE || prch->prch_st);
   return subscription_create_from_channel_or_service
            (prch, ti, weight, name, flags, hostname, username, client,
             error, NULL);
@@ -929,7 +929,7 @@ subscription_create_from_service(profile_chain_t *prch,
                                 const char *client,
                                 int *error)
 {
-  assert(prch->prch_st);
+  assert(flags == SUBSCRIPTION_NONE || prch->prch_st);
   return subscription_create_from_channel_or_service
            (prch, ti, weight, name, flags, hostname, username, client,
             error, prch->prch_id);
index 12b9652308914620892dca1caaa836426d3f6d36..5a57df9b0fcbd8c47fb7b2cbeacc26f2c70a6d0b 100644 (file)
@@ -1165,7 +1165,7 @@ http_stream_service(http_connection_t *hc, service_t *service, int weight)
   else
     qsize = 1500000;
 
-  profile_chain_init(&prch, pro, service);
+  profile_chain_init(&prch, pro, service, 1);
   if (!profile_chain_open(&prch, NULL, 0, qsize)) {
 
     s = subscription_create_from_service(&prch, NULL, weight, "HTTP",
@@ -1304,7 +1304,7 @@ http_stream_channel(http_connection_t *hc, channel_t *ch, int weight)
   else
     qsize = 1500000;
 
-  profile_chain_init(&prch, pro, ch);
+  profile_chain_init(&prch, pro, ch, 1);
   if (!profile_chain_open(&prch, NULL, 0, qsize)) {
 
     s = subscription_create_from_channel(&prch,