changeset 6479:3e7384f85f1d libavformat

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.
author mstorsjo
date Tue, 21 Sep 2010 20:17:34 +0000
parents 1e6ebac87d44
children d55dd9679e52
files tcp.c
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/tcp.c	Mon Sep 20 06:38:40 2010 +0000
+++ b/tcp.c	Tue Sep 21 20:17:34 2010 +0000
@@ -38,7 +38,7 @@
     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 @@
             }
             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;
         }