]> git.sesse.net Git - vlc/blobdiff - src/network/tcp.c
httpd: full URL is also valid for HTTP (fixes #2320)
[vlc] / src / network / tcp.c
index 9254729ca9d734826f957a81ea6243a85e20d636..814808d056b212c30d70af3f4748c91b39b126c5 100644 (file)
@@ -58,6 +58,8 @@
 #   define ETIMEDOUT WSAETIMEDOUT
 #endif
 
+#include "libvlc.h" /* vlc_object_waitpipe */
+
 static int SocksNegotiate( vlc_object_t *, int fd, int i_socks_version,
                            const char *psz_user, const char *psz_passwd );
 static int SocksHandshakeTCP( vlc_object_t *,
@@ -249,7 +251,11 @@ next_ai: /* failure */
 
 int net_AcceptSingle (vlc_object_t *obj, int lfd)
 {
-    int fd = accept (lfd, NULL, NULL);
+    int fd;
+    do
+        fd = accept (lfd, NULL, NULL);
+    while (fd == -1 && errno == EINTR);
+
     if (fd == -1)
     {
         if (net_errno != EAGAIN)
@@ -273,9 +279,6 @@ int __net_Accept( vlc_object_t *p_this, int *pi_fd, mtime_t i_wait )
     int timeout = (i_wait < 0) ? -1 : i_wait / 1000;
     int evfd = vlc_object_waitpipe (p_this);
 
-    if (evfd == -1)
-        return -1;
-
     assert( pi_fd != NULL );
 
     for (;;)
@@ -298,10 +301,13 @@ int __net_Accept( vlc_object_t *p_this, int *pi_fd, mtime_t i_wait )
         switch (poll (ufd, n, timeout))
         {
             case -1:
-                if (net_errno != EINTR)
-                    msg_Err (p_this, "poll error: %m");
+                if (net_errno == EINTR)
+                    continue;
+                msg_Err (p_this, "poll error: %m");
+                return -1;
             case 0:
-                return -1; /* NOTE: p_this already unlocked */
+                errno = ETIMEDOUT;
+                return -1;
         }
 
         if (ufd[n].revents)