Hi!

In our project we uses FFmpeg to demux RTMP streams. Input stream takes
from Wowza/nginx-rtmp. Our application is a daemon that try to connect to
source periodicaly if it does not present (does not published to Wowza, for
example). We also use interrupt callback to break connection if timeout is
occured. So in this situation:
- Alive server
- Alive streaming application
- Configured inerrupt callback with timeout
- Disalive stream

TCP socket to server does not closes.

I look into code with debugger and found place where error is occured:
rtmpproto.c, rtmp_open() L:2672

Root couse: return from function without resources clean up

Solution: replace return with 'goto fail'

Path is attached.

-- 
WBR, Alexander Drozdov
http://htrd.su
From f742012ea22bf684fe0ae8e153749bd7339503d6 Mon Sep 17 00:00:00 2001
From: Alexander Drozdov <adrozd...@gmail.com>
Date: Fri, 26 Sep 2014 09:45:08 +1100
Subject: [PATCH] RTMP: fix FD leak in rtmp_open()

If we setup AVIO interrupt callback and it will be returns 1 on socket
timeouts and we try to connect to non-existing streams on some servers
(like nginx-rtmp) we got FD leak.
---
 libavformat/rtmpproto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index 3cde966..6122548 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -2670,7 +2670,7 @@ reconnect:
         // audio or video packet arrives.
         while (!rt->has_audio && !rt->has_video && !rt->received_metadata) {
             if ((ret = get_packet(s, 0)) < 0)
-               return ret;
+               goto fail;
         }
 
         // Either after we have read the metadata or (if there is none) the
-- 
1.9.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to