diff mbox

[FFmpeg-devel,1/2] avformat/dashenc: Fix a resource leak when http persistent in enabled

Message ID 1514875698-28017-1-git-send-email-kjeyapal@akamai.com
State Superseded
Headers show

Commit Message

Jeyapal, Karthick Jan. 2, 2018, 6:48 a.m. UTC
From: Karthick Jeyapal <kjeyapal@akamai.com>

---
 libavformat/dashenc.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Liu Steven Jan. 2, 2018, 8:11 a.m. UTC | #1
> On 2 Jan 2018, at 14:48, Karthick J <kjeyapal@akamai.com> wrote:
> 
> From: Karthick Jeyapal <kjeyapal@akamai.com>
> 
> ---
> libavformat/dashenc.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
> 
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index 3345b89..c4c112b 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -1,6 +1,7 @@
> /*
>  * MPEG-DASH ISO BMFF segmenter
>  * Copyright (c) 2014 Martin Storsjo
> + * Copyright (c) 2018 Akamai Technologies, Inc.
>  *
>  * This file is part of FFmpeg.
>  *
> @@ -1317,6 +1318,16 @@ static int dash_write_trailer(AVFormatContext *s)
>     }
>     dash_flush(s, 1, -1);
> 
> +    if (c->http_persistent) {
> +        int i;
> +        for (i = 0; i < s->nb_streams; i++) {
> +            OutputStream *os = &c->streams[i];
> +            ff_format_io_close(s, &os->out);
> +        }
> +        ff_format_io_close(s, &c->mpd_out);
> +        ff_format_io_close(s, &c->m3u8_out);
> +    }
> +
>     if (c->remove_at_exit) {
>         char filename[1024];
>         int i;
> -- 
> 1.9.1
> 

LGTM

Thanks

Steven
Jeyapal, Karthick Jan. 2, 2018, 8:23 a.m. UTC | #2
On 1/2/18 1:41 PM, 刘歧 wrote:
>

>> On 2 Jan 2018, at 14:48, Karthick J <kjeyapal@akamai.com> wrote:

>>

>> From: Karthick Jeyapal <kjeyapal@akamai.com>

>>

>> ---

>> libavformat/dashenc.c | 11 +++++++++++

>> 1 file changed, 11 insertions(+)

>>

>> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c

>> index 3345b89..c4c112b 100644

>> --- a/libavformat/dashenc.c

>> +++ b/libavformat/dashenc.c

>> @@ -1,6 +1,7 @@

>> /*

>>  * MPEG-DASH ISO BMFF segmenter

>>  * Copyright (c) 2014 Martin Storsjo

>> + * Copyright (c) 2018 Akamai Technologies, Inc.

>>  *

>>  * This file is part of FFmpeg.

>>  *

>> @@ -1317,6 +1318,16 @@ static int dash_write_trailer(AVFormatContext *s)

>>     }

>>     dash_flush(s, 1, -1);

>>

>> +    if (c->http_persistent) {

>> +        int i;

>> +        for (i = 0; i < s->nb_streams; i++) {

>> +            OutputStream *os = &c->streams[i];

>> +            ff_format_io_close(s, &os->out);

>> +        }

>> +        ff_format_io_close(s, &c->mpd_out);

>> +        ff_format_io_close(s, &c->m3u8_out);

>> +    }

>> +

>>     if (c->remove_at_exit) {

>>         char filename[1024];

>>         int i;

>> -- 

>> 1.9.1

>>

>

> LGTM

Thanks. 
But I overlooked the presence dash_free function in this patch.
I have sent a new patch v2, which I think looks better than this. What do you think?
Sorry for any inconvenience caused. 
>

> Thanks

>

> Steven

>

>

>
diff mbox

Patch

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 3345b89..c4c112b 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1,6 +1,7 @@ 
 /*
  * MPEG-DASH ISO BMFF segmenter
  * Copyright (c) 2014 Martin Storsjo
+ * Copyright (c) 2018 Akamai Technologies, Inc.
  *
  * This file is part of FFmpeg.
  *
@@ -1317,6 +1318,16 @@  static int dash_write_trailer(AVFormatContext *s)
     }
     dash_flush(s, 1, -1);
 
+    if (c->http_persistent) {
+        int i;
+        for (i = 0; i < s->nb_streams; i++) {
+            OutputStream *os = &c->streams[i];
+            ff_format_io_close(s, &os->out);
+        }
+        ff_format_io_close(s, &c->mpd_out);
+        ff_format_io_close(s, &c->m3u8_out);
+    }
+
     if (c->remove_at_exit) {
         char filename[1024];
         int i;