]> git.sesse.net Git - vlc/blobdiff - src/network/io.c
Disable live555 in distcheck
[vlc] / src / network / io.c
index 8bbb1bca24cbaeae1d2277ec0aa37423953dc61e..0491c3992bdcbc34561684257a3083b019928793 100644 (file)
@@ -32,7 +32,7 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -370,16 +370,16 @@ __net_Read (vlc_object_t *restrict p_this, int fd, const v_socket_t *vs,
                                      "Increase the mtu size (--mtu option)");
                     n = i_buflen;
                     break;
-
-                default:
-                    goto error;
             }
 #else
-            /* spurious wake-up or TLS did not yield any actual data */
-            if (errno == EAGAIN)
-                continue;
-            goto error;
+            switch (errno)
+            {
+                case EAGAIN: /* spurious wakeup or no TLS data */
+                case EINTR:  /* asynchronous signal */
+                    continue;
+            }
 #endif
+            goto error;
         }
 
         if (n == 0)
@@ -429,20 +429,19 @@ ssize_t __net_Write( vlc_object_t *p_this, int fd, const v_socket_t *p_vs,
 
         if (poll (ufd, 1, -1) == -1)
         {
-            if (errno != EINTR)
-            {
-                msg_Err (p_this, "Write error: %m");
-                goto error;
-            }
-            continue;
+            if (errno == EINTR)
+                continue;
+            msg_Err (p_this, "Polling error: %m");
+            return -1;
         }
 
         if (i_total > 0)
-        {
-            /* Errors will be dequeued separately, upon next call. */
-            if (ufd[0].revents & (POLLERR|POLLNVAL|POLLHUP))
+        {   /* If POLLHUP resp. POLLERR|POLLNVAL occurs while we have already
+             * read some data, it is important that we first return the number
+             * of bytes read, and then return 0 resp. -1 on the NEXT call. */
+            if (ufd[0].revents & (POLLHUP|POLLERR|POLLNVAL))
                 break;
-            if (ufd[1].revents)
+            if (ufd[1].revents) /* VLC object signaled */
                 break;
         }
         else
@@ -466,6 +465,8 @@ ssize_t __net_Write( vlc_object_t *p_this, int fd, const v_socket_t *p_vs,
 
         if (val == -1)
         {
+            if (errno == EINTR)
+                continue;
             msg_Err (p_this, "Write error: %m");
             break;
         }
@@ -552,9 +553,9 @@ ssize_t __net_vaPrintf( vlc_object_t *p_this, int fd, const v_socket_t *p_vs,
 /*****************************************************************************
  * inet_pton replacement for obsolete and/or crap operating systems
  *****************************************************************************/
-#ifndef HAVE_INET_PTON
-int inet_pton(int af, const char *src, void *dst)
+int vlc_inet_pton(int af, const char *src, void *dst)
 {
+#ifndef HAVE_INET_PTON
 # ifdef WIN32
     /* As we already know, Microsoft always go its own way, so even if they do
      * provide IPv6, they don't provide the API. */
@@ -612,14 +613,16 @@ int inet_pton(int af, const char *src, void *dst)
     memcpy( dst, &ipv4, 4 );
 # endif /* WIN32 */
     return 0;
-}
+#else /* HAVE_INET_PTON */
+    return inet_pton( af, src, dst );
 #endif /* HAVE_INET_PTON */
+}
 
-#ifndef HAVE_INET_NTOP
-#ifdef WIN32
-const char *inet_ntop(int af, const void * src,
+const char *vlc_inet_ntop(int af, const void * src,
                                char * dst, socklen_t cnt)
 {
+#ifndef HAVE_INET_NTOP
+#ifdef WIN32
     switch( af )
     {
 #ifdef AF_INET6
@@ -662,6 +665,25 @@ const char *inet_ntop(int af, const void * src,
     }
     errno = EAFNOSUPPORT;
     return NULL;
+#else /* WIN32 */
+    return NULL;
+#endif /* WIN32 */
+#else /* HAVE_INET_NTOP */
+    return inet_ntop( af, src, dst, cnt );
+#endif /* HAVE_INET_NTOP */
 }
-#endif
-#endif
+
+#ifdef WIN32
+    /* vlc_sendmsg, vlc_recvmsg Defined in winsock.c */
+#else /* !WIN32 */
+ssize_t vlc_sendmsg (int s, struct msghdr *hdr, int flags)
+{
+    return sendmsg (s, hdr, flags);
+}
+
+ssize_t vlc_recvmsg (int s, struct msghdr *hdr, int flags)
+{
+    return recvmsg (s, hdr, flags);
+}
+#endif /* WIN32 */
+