]> git.sesse.net Git - vlc/blobdiff - src/network/tcp.c
Remove Unneeded test (thx ipkiss)
[vlc] / src / network / tcp.c
index 20a31d5c4fed6c914672dda3aeb45ea7aada4f67..e027e277be6106fb2751a1fb344fe8b23bdd8dbc 100644 (file)
@@ -30,7 +30,7 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 
 #include <errno.h>
 #include <assert.h>
@@ -58,7 +58,7 @@
 #   define ETIMEDOUT WSAETIMEDOUT
 #endif
 
-static int SocksNegociate( vlc_object_t *, int fd, int i_socks_version,
+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 *,
                               int fd, int i_socks_version,
@@ -161,7 +161,7 @@ int __net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
         {
             int timeout, val;
 
-            if( net_errno != EINPROGRESS )
+            if( net_errno != EINPROGRESS && net_errno != EINTR )
             {
                 msg_Err( p_this, "connection failed: %m" );
                 goto next_ai;
@@ -249,7 +249,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)
@@ -298,10 +302,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)
@@ -334,11 +341,11 @@ int __net_Accept( vlc_object_t *p_this, int *pi_fd, mtime_t i_wait )
 
 
 /*****************************************************************************
- * SocksNegociate:
+ * SocksNegotiate:
  *****************************************************************************
- * Negociate authentication with a SOCKS server.
+ * Negotiate authentication with a SOCKS server.
  *****************************************************************************/
-static int SocksNegociate( vlc_object_t *p_obj,
+static int SocksNegotiate( vlc_object_t *p_obj,
                            int fd, int i_socks_version,
                            const char *psz_socks_user,
                            const char *psz_socks_passwd )
@@ -350,7 +357,7 @@ static int SocksNegociate( vlc_object_t *p_obj,
     if( i_socks_version != 5 )
         return VLC_SUCCESS;
 
-    /* We negociate authentication */
+    /* We negotiate authentication */
 
     if( ( psz_socks_user == NULL ) && ( psz_socks_passwd == NULL ) )
         b_auth = true;
@@ -442,7 +449,7 @@ static int SocksHandshakeTCP( vlc_object_t *p_obj,
     }
 
     if( i_socks_version == 5 &&
-        SocksNegociate( p_obj, fd, i_socks_version,
+        SocksNegotiate( p_obj, fd, i_socks_version,
                         psz_user, psz_passwd ) )
         return VLC_EGENERIC;