- struct pollfd ufd = { .fd = fd, .events = POLLOUT };
- int i_ret;
-
- if( p_this->b_die )
- {
- msg_Dbg( p_this, "connection aborted" );
- net_Close( fd );
- vlc_freeaddrinfo( res );
- return -1;
- }
-
- /*
- * We'll wait 0.1 second if nothing happens
- * NOTE:
- * time out will be shortened if we catch a signal (EINTR)
- */
- i_ret = poll (&ufd, 1, (d.quot > 0) ? 100 : d.rem);
- if( i_ret == 1 )
- break;
-
- if( ( i_ret == -1 ) && ( net_errno != EINTR ) )
- {
- msg_Err( p_this, "connection polling error: %m" );
- goto next_ai;
- }
-
- if( d.quot <= 0 )
- {
- msg_Warn( p_this, "connection timed out" );
- 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 */