aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2010-09-21 20:17:34 +0000
committerMartin Storsjö <martin@martin.st>2010-09-21 20:17:34 +0000
commitb41626762253e3d08f8a61db36fcbd1766e4de09 (patch)
tree1d7b850e93c352787ac5d6b9bbd621c78b5002a8
parentc0bc8b9afb7e4f39d84080870b9feedcd23ab5c9 (diff)
downloadffmpeg-b41626762253e3d08f8a61db36fcbd1766e4de09.tar.gz
tcp: Check both wfds and efds when waiting for the result from connect
On windows, a connection failure doesn't trigger wfds as it does on unix. This fixes issue 2237, based on code by yeyingxian. Originally committed as revision 25154 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavformat/tcp.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index ca4a6b0b25..12792b5470 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -38,7 +38,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
struct addrinfo hints, *ai, *cur_ai;
int port, fd = -1;
TCPContext *s = NULL;
- fd_set wfds;
+ fd_set wfds, efds;
int fd_max, ret;
struct timeval tv;
socklen_t optlen;
@@ -87,11 +87,13 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
}
fd_max = fd;
FD_ZERO(&wfds);
+ FD_ZERO(&efds);
FD_SET(fd, &wfds);
+ FD_SET(fd, &efds);
tv.tv_sec = 0;
tv.tv_usec = 100 * 1000;
- ret = select(fd_max + 1, NULL, &wfds, NULL, &tv);
- if (ret > 0 && FD_ISSET(fd, &wfds))
+ ret = select(fd_max + 1, NULL, &wfds, &efds, &tv);
+ if (ret > 0 && (FD_ISSET(fd, &wfds) || FD_ISSET(fd, &efds)))
break;
}