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

select() sucks

parent 3b396a3d
...@@ -135,7 +135,6 @@ int __net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port, ...@@ -135,7 +135,6 @@ int __net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
{ {
socklen_t i_val_size = sizeof( i_val ); socklen_t i_val_size = sizeof( i_val );
div_t d; div_t d;
struct timeval tv;
vlc_value_t timeout; vlc_value_t timeout;
if( net_errno != EINPROGRESS ) if( net_errno != EINPROGRESS )
...@@ -162,7 +161,7 @@ int __net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port, ...@@ -162,7 +161,7 @@ int __net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
msg_Dbg( p_this, "connection in progress" ); msg_Dbg( p_this, "connection in progress" );
for (;;) for (;;)
{ {
fd_set fds; struct pollfd ufd = { .fd = fd, .events = POLLOUT };
int i_ret; int i_ret;
if( p_this->b_die ) if( p_this->b_die )
...@@ -174,19 +173,12 @@ int __net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port, ...@@ -174,19 +173,12 @@ int __net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
return -1; return -1;
} }
/* Initialize file descriptor set */
FD_ZERO( &fds );
FD_SET( fd, &fds );
/* /*
* We'll wait 0.1 second if nothing happens * We'll wait 0.1 second if nothing happens
* NOTE: * NOTE:
* time out will be shortened if we catch a signal (EINTR) * time out will be shortened if we catch a signal (EINTR)
*/ */
tv.tv_sec = 0; i_ret = poll (&ufd, 1, (d.quot > 0) ? 100 : d.rem);
tv.tv_usec = (d.quot > 0) ? 100000 : (1000 * d.rem);
i_ret = select( fd + 1, NULL, &fds, NULL, &tv );
if( i_ret == 1 ) if( i_ret == 1 )
break; break;
......
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