Commit 2bd02c89 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

network: use vlc_poll_i11e() instead of wait pipe in net_Connect()

parent a207f20f
...@@ -47,11 +47,8 @@ ...@@ -47,11 +47,8 @@
# define EWOULDBLOCK WSAEWOULDBLOCK # define EWOULDBLOCK WSAEWOULDBLOCK
# undef EAGAIN # undef EAGAIN
# define EAGAIN WSAEWOULDBLOCK # define EAGAIN WSAEWOULDBLOCK
# undef EINTR
# define EINTR WSAEINTR
#endif #endif
#include <vlc_interrupt.h>
#include "libvlc.h" /* vlc_object_waitpipe */
static int SocksNegotiate( vlc_object_t *, int fd, int i_socks_version, static int SocksNegotiate( vlc_object_t *, int fd, int i_socks_version,
const char *psz_user, const char *psz_passwd ); 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, ...@@ -76,10 +73,6 @@ int net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
char *psz_socks; char *psz_socks;
int i_realport, i_handle = -1; 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" ); psz_socks = var_InheritString( p_this, "socks" );
if( psz_socks != NULL ) if( psz_socks != NULL )
{ {
...@@ -160,22 +153,26 @@ int net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port, ...@@ -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( 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", msg_Err( p_this, "connection failed: %s",
vlc_strerror_c(net_errno) ); vlc_strerror_c(net_errno) );
goto next_ai; goto next_ai;
} }
struct pollfd ufd[2] = { struct pollfd ufd;
{ .fd = fd, .events = POLLOUT },
{ .fd = evfd, .events = POLLIN }, ufd.fd = fd;
}; ufd.events = POLLOUT;
do do /* NOTE: timeout screwed up if we catch a signal (EINTR) */
/* NOTE: timeout screwed up if we catch a signal (EINTR) */ {
val = poll (ufd, sizeof (ufd) / sizeof (ufd[0]), timeout); if (!vlc_object_alive(p_this))
while ((val == -1) && (net_errno == EINTR)); goto next_ai;
val = vlc_poll_i11e(&ufd, 1, timeout);
}
while (val == -1 && errno == EINTR);
switch (val) switch (val)
{ {
...@@ -187,10 +184,6 @@ int net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port, ...@@ -187,10 +184,6 @@ int net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
case 0: /* timeout */ case 0: /* timeout */
msg_Warn (p_this, "connection timed out"); msg_Warn (p_this, "connection timed out");
goto next_ai; goto next_ai;
default: /* something happended */
if (ufd[1].revents)
goto next_ai; /* LibVLC object killed */
} }
/* There is NO WAY around checking SO_ERROR. /* There is NO WAY around checking SO_ERROR.
......
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