1
mirror of https://git.videolan.org/git/ffmpeg.git synced 2024-09-15 11:28:55 +02:00

Timeout TCP open() after 5 seconds.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2011-04-02 00:29:07 +02:00
parent ecf94986c8
commit a2f5e14a86

View File

@ -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 */