diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-04-02 00:29:07 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-04-02 00:56:43 +0200 |
commit | a2f5e14a867768019b49b830e29801f1bfb2abb7 (patch) | |
tree | 33040dcbf65d9a7ada6c38e3627652ccbf719f0f /libavformat | |
parent | ecf94986c8ba7c9fb4f674ee93e3be5f73d8ccdd (diff) | |
download | ffmpeg-a2f5e14a867768019b49b830e29801f1bfb2abb7.tar.gz |
Timeout TCP open() after 5 seconds.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/tcp.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libavformat/tcp.c b/libavformat/tcp.c index 83529dfcc4..fb94b63984 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 */ |