- fd_set fds;
- int i_ret;
-
- if( p_this->b_die )
- {
- msg_Dbg( p_this, "connection aborted" );
- net_Close( fd );
- vlc_freeaddrinfo( res );
- free( psz_socks );
- return -1;
- }
-
- /* Initialize file descriptor set */
- FD_ZERO( &fds );
- FD_SET( fd, &fds );
-
- /*
- * We'll wait 0.1 second if nothing happens
- * NOTE:
- * time out will be shortened if we catch a signal (EINTR)
- */
- tv.tv_sec = 0;
- tv.tv_usec = (d.quot > 0) ? 100000 : (1000 * d.rem);
-
- i_ret = select( fd + 1, NULL, &fds, NULL, &tv );
- if( i_ret == 1 )
- break;
-
- if( ( i_ret == -1 ) && ( net_errno != EINTR ) )
- {
- msg_Warn( p_this, "select error: %s",
- strerror( net_errno ) );
- goto next_ai;
- }
-
- if( d.quot <= 0 )
- {
- msg_Dbg( p_this, "select timed out" );
- if( u_errstep <= 2 )
- {
- u_errstep = 3;
- i_saved_errno = ETIMEDOUT;
- }
- goto next_ai;
- }
-
- d.quot--;
+ case -1: /* error */
+ msg_Err (p_this, "connection polling error: %m");
+ goto next_ai;
+
+ 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 */