[vlc-commits] network: use vlc_poll_i11e() instead of wait pipe in net_Connect()
Rémi Denis-Courmont
git at videolan.org
Wed Jul 1 18:22:10 CEST 2015
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Jun 30 23:52:51 2015 +0300| [2bd02c89b2af00c4ef3624500bf3c343f6d49324] | committer: Rémi Denis-Courmont
network: use vlc_poll_i11e() instead of wait pipe in net_Connect()
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2bd02c89b2af00c4ef3624500bf3c343f6d49324
---
src/network/tcp.c | 35 ++++++++++++++---------------------
1 file changed, 14 insertions(+), 21 deletions(-)
diff --git a/src/network/tcp.c b/src/network/tcp.c
index f999aaf..8e201cf 100644
--- a/src/network/tcp.c
+++ b/src/network/tcp.c
@@ -47,11 +47,8 @@
# define EWOULDBLOCK WSAEWOULDBLOCK
# undef EAGAIN
# define EAGAIN WSAEWOULDBLOCK
-# undef EINTR
-# define EINTR WSAEINTR
#endif
-
-#include "libvlc.h" /* vlc_object_waitpipe */
+#include <vlc_interrupt.h>
static int SocksNegotiate( vlc_object_t *, int fd, int i_socks_version,
const char *psz_user, const char *psz_passwd );
@@ -76,10 +73,6 @@ int net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
char *psz_socks;
int i_realport, i_handle = -1;
- int evfd = vlc_object_waitpipe (p_this);
- if (evfd == -1)
- return -1;
-
psz_socks = var_InheritString( p_this, "socks" );
if( psz_socks != NULL )
{
@@ -160,22 +153,26 @@ int net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
if( connect( fd, ptr->ai_addr, ptr->ai_addrlen ) )
{
- if( net_errno != EINPROGRESS && net_errno != EINTR )
+ if( net_errno != EINPROGRESS && errno != EINTR )
{
msg_Err( p_this, "connection failed: %s",
vlc_strerror_c(net_errno) );
goto next_ai;
}
- struct pollfd ufd[2] = {
- { .fd = fd, .events = POLLOUT },
- { .fd = evfd, .events = POLLIN },
- };
+ struct pollfd ufd;
+
+ ufd.fd = fd;
+ ufd.events = POLLOUT;
- do
- /* NOTE: timeout screwed up if we catch a signal (EINTR) */
- val = poll (ufd, sizeof (ufd) / sizeof (ufd[0]), timeout);
- while ((val == -1) && (net_errno == EINTR));
+ do /* NOTE: timeout screwed up if we catch a signal (EINTR) */
+ {
+ if (!vlc_object_alive(p_this))
+ goto next_ai;
+
+ val = vlc_poll_i11e(&ufd, 1, timeout);
+ }
+ while (val == -1 && errno == EINTR);
switch (val)
{
@@ -187,10 +184,6 @@ int net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
case 0: /* timeout */
msg_Warn (p_this, "connection timed out");
goto next_ai;
-
- default: /* something happended */
- if (ufd[1].revents)
- goto next_ai; /* LibVLC object killed */
}
/* There is NO WAY around checking SO_ERROR.
More information about the vlc-commits
mailing list