]> 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 15:10:06 +0000 (16:10 +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 fe1b96a07efa6d14f232d99d2c61bc6f9f5b9fdf..8add06be6158d3536687f0491e71a3963c4bdd32 100644 (file)
@@ -138,13 +138,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, NULL, 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, channel_blank_name));
     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, NULL, 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, channel_blank_name));
index bc1ce16ce0001989a974bc5ba000b8ed238b271b..aa5f02b39f9c88bb30a31e914562ae99b53ef7fb 100644 (file)
@@ -2548,7 +2548,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 4f710b07d15809f097998c12d1e2866378f897ac..f439447749ee56e0f0af278c79ed93240060392e 100644 (file)
@@ -1020,15 +1020,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 0c6e623d8396ec2a974b66841351498f0ae8e2f3..196c612db92c114d74dd461f7484bf0636f859fe 100644 (file)
@@ -182,7 +182,7 @@ int profile_chain_open(profile_chain_t *prch,
                        muxer_config_t *m_cfg,
                        muxer_hints_t *hints,
                        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 6aa2c7527aeb3098b430f9f032aeed5845d7b1f5..ec16858997836a02ed270bbaee55b9d0c2a970ad 100644 (file)
@@ -391,9 +391,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 122b3a19fd6693643791531757fd66b21a86c7aa..84e77873136ba535e8a68fcebf1f1cf787ea32d6 100644 (file)
@@ -369,7 +369,7 @@ service_mapper_thread ( void *aux )
   const char *err = NULL;
   uint64_t timeout, timeout_other;
 
-  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 8c977725c76d24daccd9aa967da0d9b073de33fc..032f484a2b8c7da777c9c2f1ea99ea6caa76cc7d 100644 (file)
@@ -916,7 +916,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);
@@ -936,7 +936,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 feb455096c19f7915bd4649b4d046aaf8c114973..942a104f9f2c2049c4adb885ee352211e6014b57 100644 (file)
@@ -1172,7 +1172,7 @@ http_stream_service(http_connection_t *hc, service_t *service, int weight)
 
   hints = muxer_hints_create(http_arg_get(&hc->hc_args, "User-Agent"));
 
-  profile_chain_init(&prch, pro, service);
+  profile_chain_init(&prch, pro, service, 1);
   if (!profile_chain_open(&prch, NULL, hints, 0, qsize)) {
 
     s = subscription_create_from_service(&prch, NULL, weight, "HTTP",
@@ -1314,7 +1314,7 @@ http_stream_channel(http_connection_t *hc, channel_t *ch, int weight)
 
   hints = muxer_hints_create(http_arg_get(&hc->hc_args, "User-Agent"));
 
-  profile_chain_init(&prch, pro, ch);
+  profile_chain_init(&prch, pro, ch, 1);
   if (!profile_chain_open(&prch, NULL, hints, 0, qsize)) {
 
     s = subscription_create_from_channel(&prch,