From: Rémi Denis-Courmont Date: Sun, 10 Feb 2008 15:43:05 +0000 (+0000) Subject: Fix net_Write waitpipe usage, cleanups X-Git-Tag: 0.9.0-test0~2718 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=0b28505c862d23805402d4549a61470b9c53b79f;p=vlc Fix net_Write waitpipe usage, cleanups --- diff --git a/src/network/io.c b/src/network/io.c index 326131abee..c8b955c29e 100644 --- a/src/network/io.c +++ b/src/network/io.c @@ -280,32 +280,15 @@ __net_Read (vlc_object_t *restrict p_this, int fd, const v_socket_t *vs, while (i_buflen > 0) { - int val; - ufd[0].revents = ufd[1].revents = 0; - val = poll (ufd, sizeof (ufd) / sizeof (ufd[0]), -1); - - if (val < 0) - goto error; - - if (ufd[1].revents) + if (poll (ufd, sizeof (ufd) / sizeof (ufd[0]), -1) < 0) { - msg_Dbg (p_this, "socket %d polling interrupted", fd); - if (i_total == 0) - { -#if defined(WIN32) || defined(UNDER_CE) - WSASetLastError (WSAEINTR); -#else - errno = EINTR; -#endif + if (errno =! EINTR) goto error; - } - break; + continue; } - assert (ufd[0].revents); - #ifndef POLLRDHUP /* This is nice but non-portable */ # define POLLRDHUP 0 #endif @@ -316,8 +299,25 @@ __net_Read (vlc_object_t *restrict p_this, int fd, const v_socket_t *vs, * bad idea™. */ if (ufd[0].revents & (POLLERR|POLLNVAL|POLLRDHUP)) 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; if (vs != NULL) { @@ -416,8 +416,14 @@ ssize_t __net_Write( vlc_object_t *p_this, int fd, const v_socket_t *p_vs, continue; } - if ((ufd[0].revents & (POLLERR|POLLNVAL|POLLHUP)) && (i_total > 0)) - break; // error will be dequeued separately on next call + if (i_total > 0) + { + /* 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) val = p_vs->pf_send (p_vs->p_sys, p_data, i_data);