Commit 0b28505c authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Fix net_Write waitpipe usage, cleanups

parent 58bd68a6
...@@ -280,32 +280,15 @@ __net_Read (vlc_object_t *restrict p_this, int fd, const v_socket_t *vs, ...@@ -280,32 +280,15 @@ __net_Read (vlc_object_t *restrict p_this, int fd, const v_socket_t *vs,
while (i_buflen > 0) while (i_buflen > 0)
{ {
int val;
ufd[0].revents = ufd[1].revents = 0; ufd[0].revents = ufd[1].revents = 0;
val = poll (ufd, sizeof (ufd) / sizeof (ufd[0]), -1); if (poll (ufd, sizeof (ufd) / sizeof (ufd[0]), -1) < 0)
if (val < 0)
goto error;
if (ufd[1].revents)
{ {
msg_Dbg (p_this, "socket %d polling interrupted", fd); if (errno =! EINTR)
if (i_total == 0)
{
#if defined(WIN32) || defined(UNDER_CE)
WSASetLastError (WSAEINTR);
#else
errno = EINTR;
#endif
goto error; goto error;
} continue;
break;
} }
assert (ufd[0].revents);
#ifndef POLLRDHUP /* This is nice but non-portable */ #ifndef POLLRDHUP /* This is nice but non-portable */
# define POLLRDHUP 0 # define POLLRDHUP 0
#endif #endif
...@@ -316,8 +299,25 @@ __net_Read (vlc_object_t *restrict p_this, int fd, const v_socket_t *vs, ...@@ -316,8 +299,25 @@ __net_Read (vlc_object_t *restrict p_this, int fd, const v_socket_t *vs,
* bad idea™. */ * bad idea™. */
if (ufd[0].revents & (POLLERR|POLLNVAL|POLLRDHUP)) if (ufd[0].revents & (POLLERR|POLLNVAL|POLLRDHUP))
break; break;
if (ufd[1].revents)
break;
}
else
{
if (ufd[1].revents)
{
msg_Dbg (p_this, "socket %d polling interrupted", fd);
#if defined(WIN32) || defined(UNDER_CE)
WSASetLastError (WSAEINTR);
#else
errno = EINTR;
#endif
goto error;
}
} }
assert (ufd[0].revents);
ssize_t n; ssize_t n;
if (vs != NULL) if (vs != NULL)
{ {
...@@ -416,8 +416,14 @@ ssize_t __net_Write( vlc_object_t *p_this, int fd, const v_socket_t *p_vs, ...@@ -416,8 +416,14 @@ ssize_t __net_Write( vlc_object_t *p_this, int fd, const v_socket_t *p_vs,
continue; continue;
} }
if ((ufd[0].revents & (POLLERR|POLLNVAL|POLLHUP)) && (i_total > 0)) if (i_total > 0)
break; // error will be dequeued separately on next call {
/* Errors will be dequeued separately, upon next call. */
if (ufd[0].revents & (POLLERR|POLLNVAL|POLLHUP))
break;
if (ufd[1].revents)
break;
}
if (p_vs != NULL) if (p_vs != NULL)
val = p_vs->pf_send (p_vs->p_sys, p_data, i_data); val = p_vs->pf_send (p_vs->p_sys, p_data, i_data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment