Commit a2f5e14a authored by Michael Niedermayer's avatar Michael Niedermayer

Timeout TCP open() after 5 seconds.

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent ecf94986
...@@ -71,6 +71,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags) ...@@ -71,6 +71,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
redo: redo:
ret = connect(fd, cur_ai->ai_addr, cur_ai->ai_addrlen); ret = connect(fd, cur_ai->ai_addr, cur_ai->ai_addrlen);
if (ret < 0) { if (ret < 0) {
int timeout=50;
struct pollfd p = {fd, POLLOUT, 0}; struct pollfd p = {fd, POLLOUT, 0};
if (ff_neterrno() == AVERROR(EINTR)) { if (ff_neterrno() == AVERROR(EINTR)) {
if (url_interrupt_cb()) { if (url_interrupt_cb()) {
...@@ -92,6 +93,12 @@ static int tcp_open(URLContext *h, const char *uri, int flags) ...@@ -92,6 +93,12 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
ret = poll(&p, 1, 100); ret = poll(&p, 1, 100);
if (ret > 0) if (ret > 0)
break; break;
if(!--timeout){
av_log(NULL, AV_LOG_ERROR,
"TCP open %s:%d timeout\n",
hostname, port);
goto fail;
}
} }
/* test error */ /* test error */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment