Remove usage of exceptional fdsets with select().

This commit is contained in:
John Hood
2015-12-28 06:07:28 -05:00
parent 19f214e46d
commit ca21788c96
6 changed files with 3 additions and 49 deletions
-4
View File
@@ -153,10 +153,6 @@ int main( int argc, char *argv[] )
/* we only read one socket each run */
network_ready_to_read = true;
}
if ( sel.error( *it ) ) {
break;
}
}
if ( network_ready_to_read ) {
-2
View File
@@ -158,8 +158,6 @@ static void emulate_terminal( int fd )
if ( vt_parser( fd, &parser ) < 0 ) {
return;
}
} else if ( sel.error( STDIN_FILENO ) || sel.error( fd ) ) {
return;
} else {
fprintf( stderr, "select mysteriously woken up\n" );
}
-2
View File
@@ -311,8 +311,6 @@ static void emulate_terminal( int fd )
perror( "ioctl TIOCSWINSZ" );
return;
}
} else if ( sel.error( STDIN_FILENO ) || sel.error( fd ) ) {
break;
}
Terminal::Framebuffer new_frame( complete.get_fb() );
-10
View File
@@ -765,16 +765,6 @@ static void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &
}
}
if ( sel.error( network_fd ) ) {
/* network problem */
break;
}
if ( (!network.shutdown_in_progress()) && sel.error( host_fd ) ) {
/* host problem */
network.start_shutdown();
}
/* quit if our shutdown has been acknowledged */
if ( network.shutdown_in_progress() && network.shutdown_acknowledged() ) {
break;
-15
View File
@@ -448,11 +448,6 @@ bool STMClient::main( void )
/* we only read one socket each run */
network_ready_to_read = true;
}
if ( sel.error( *it ) ) {
/* network problem */
break;
}
}
if ( network_ready_to_read ) {
@@ -493,16 +488,6 @@ bool STMClient::main( void )
}
}
if ( sel.error( STDIN_FILENO ) ) {
/* user problem */
if ( !network->has_remote_addr() ) {
break;
} else if ( !network->shutdown_in_progress() ) {
overlays.get_notification_engine().set_notification_string( wstring( L"Exiting..." ), true );
network->start_shutdown();
}
}
/* quit if our shutdown has been acknowledged */
if ( network->shutdown_in_progress() && network->shutdown_acknowledged() ) {
clean_shutdown = true;
+3 -16
View File
@@ -62,12 +62,10 @@ private:
here to appease -Weffc++. */
, all_fds( dummy_fd_set )
, read_fds( dummy_fd_set )
, error_fds( dummy_fd_set )
, empty_sigset( dummy_sigset )
{
FD_ZERO( &all_fds );
FD_ZERO( &read_fds );
FD_ZERO( &error_fds );
clear_got_signal();
fatal_assert( 0 == sigemptyset( &empty_sigset ) );
@@ -120,7 +118,6 @@ public:
int select( int timeout )
{
memcpy( &read_fds, &all_fds, sizeof( read_fds ) );
memcpy( &error_fds, &all_fds, sizeof( error_fds ) );
clear_got_signal();
#ifdef HAVE_PSELECT
@@ -133,7 +130,7 @@ public:
tsp = &ts;
}
int ret = ::pselect( max_fd + 1, &read_fds, NULL, &error_fds, tsp, &empty_sigset );
int ret = ::pselect( max_fd + 1, &read_fds, NULL, NULL, tsp, &empty_sigset );
#else
struct timeval tv;
struct timeval *tvp = NULL;
@@ -147,7 +144,7 @@ public:
int ret = sigprocmask( SIG_SETMASK, &empty_sigset, &old_sigset );
if ( ret != -1 ) {
ret = ::select( max_fd + 1, &read_fds, NULL, &error_fds, tvp );
ret = ::select( max_fd + 1, &read_fds, NULL, NULL, tvp );
sigprocmask( SIG_SETMASK, &old_sigset, NULL );
}
#endif
@@ -155,7 +152,6 @@ public:
if ( ( ret == -1 ) && ( errno == EINTR ) ) {
/* The user should process events as usual. */
FD_ZERO( &read_fds );
FD_ZERO( &error_fds );
ret = 0;
}
@@ -173,15 +169,6 @@ public:
return FD_ISSET( fd, &read_fds );
}
bool error( int fd )
#if FD_ISSET_IS_CONST
const
#endif
{
assert( FD_ISSET( fd, &all_fds ) );
return FD_ISSET( fd, &error_fds );
}
/* This method consumes a signal notification. */
bool signal( int signum )
{
@@ -214,7 +201,7 @@ private:
concurrent signal handlers. */
int got_signal[ MAX_SIGNAL_NUMBER + 1 ];
fd_set all_fds, read_fds, error_fds;
fd_set all_fds, read_fds;
sigset_t empty_sigset;