]> git.sesse.net Git - vlc/blobdiff - src/network/io.c
Merge branch 1.0-bugfix
[vlc] / src / network / io.c
index a0ece78470d2716d6911fea2ed8a4ce294814a6d..313e0e8a9494ce83aa46d4ca5ba638d060e0832c 100644 (file)
@@ -219,8 +219,8 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host,
             net_Close (fd);
 #if !defined(WIN32) && !defined(UNDER_CE)
             fd = rootwrap_bind (ptr->ai_family, socktype,
-                                protocol ?: ptr->ai_protocol, ptr->ai_addr,
-                                ptr->ai_addrlen);
+                                protocol ? protocol : ptr->ai_protocol,
+                                ptr->ai_addr, ptr->ai_addrlen);
             if (fd != -1)
             {
                 msg_Dbg (p_this, "got socket %d from rootwrap", fd);
@@ -281,7 +281,7 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host,
 /*****************************************************************************
  * __net_Read:
  *****************************************************************************
- * Reads from a network socket.
+ * Reads from a network socket. Cancellation point.
  * If waitall is true, then we repeat until we have read the right amount of
  * data; in that case, a short count means EOF has been reached or the VLC
  * object has been signaled.
@@ -343,7 +343,9 @@ __net_Read (vlc_object_t *restrict p_this, int fd, const v_socket_t *vs,
         ssize_t n;
         if (vs != NULL)
         {
+            int canc = vlc_savecancel ();
             n = vs->pf_recv (vs->p_sys, p_buf, i_buflen);
+            vlc_restorecancel (canc);
         }
         else
         {
@@ -377,6 +379,9 @@ __net_Read (vlc_object_t *restrict p_this, int fd, const v_socket_t *vs,
             switch (errno)
             {
                 case EAGAIN: /* spurious wakeup or no TLS data */
+#if (EAGAIN != EWOULDBLOCK)
+                case EWOULDBLOCK:
+#endif
                 case EINTR:  /* asynchronous signal */
                     continue;
             }
@@ -429,7 +434,7 @@ ssize_t __net_Write( vlc_object_t *p_this, int fd, const v_socket_t *p_vs,
 
         ufd[0].revents = ufd[1].revents = 0;
 
-        if (poll (ufd, 1, -1) == -1)
+        if (poll (ufd, sizeof (ufd) / sizeof (ufd[0]), -1) == -1)
         {
             if (errno == EINTR)
                 continue;
@@ -559,18 +564,3 @@ ssize_t __net_vaPrintf( vlc_object_t *p_this, int fd, const v_socket_t *p_vs,
 
     return i_ret;
 }
-
-#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 */
-