[FFmpeg-cvslog] Timeout TCP open() after 5 seconds.

Michael Niedermayer git at videolan.org
Sat Apr 2 01:00:17 CEST 2011


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sat Apr  2 00:29:07 2011 +0200| [a2f5e14a867768019b49b830e29801f1bfb2abb7] | committer: Michael Niedermayer

Timeout TCP open() after 5 seconds.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a2f5e14a867768019b49b830e29801f1bfb2abb7
---

 libavformat/tcp.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index 83529df..fb94b63 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -71,6 +71,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
  redo:
     ret = connect(fd, cur_ai->ai_addr, cur_ai->ai_addrlen);
     if (ret < 0) {
+        int timeout=50;
         struct pollfd p = {fd, POLLOUT, 0};
         if (ff_neterrno() == AVERROR(EINTR)) {
             if (url_interrupt_cb()) {
@@ -92,6 +93,12 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
             ret = poll(&p, 1, 100);
             if (ret > 0)
                 break;
+            if(!--timeout){
+                av_log(NULL, AV_LOG_ERROR,
+                    "TCP open %s:%d timeout\n",
+                    hostname, port);
+                goto fail;
+            }
         }
 
         /* test error */



More information about the ffmpeg-cvslog mailing list