Collapse nested conditionals.
This commit is contained in:
@@ -826,13 +826,12 @@ static void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &
|
|||||||
fprintf( stderr, "Network idle for %llu seconds.\n",
|
fprintf( stderr, "Network idle for %llu seconds.\n",
|
||||||
static_cast<unsigned long long>( time_since_remote_state / 1000 ) );
|
static_cast<unsigned long long>( time_since_remote_state / 1000 ) );
|
||||||
}
|
}
|
||||||
if ( sel.signal( SIGUSR1 ) ) {
|
if ( sel.signal( SIGUSR1 )
|
||||||
if ( !network_signaled_timeout_ms || network_signaled_timeout_ms <= time_since_remote_state ) {
|
&& ( !network_signaled_timeout_ms || network_signaled_timeout_ms <= time_since_remote_state ) ) {
|
||||||
idle_shutdown = true;
|
idle_shutdown = true;
|
||||||
fprintf( stderr, "Network idle for %llu seconds when SIGUSR1 received\n",
|
fprintf( stderr, "Network idle for %llu seconds when SIGUSR1 received\n",
|
||||||
static_cast<unsigned long long>( time_since_remote_state / 1000 ) );
|
static_cast<unsigned long long>( time_since_remote_state / 1000 ) );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( sel.any_signal() || idle_shutdown ) {
|
if ( sel.any_signal() || idle_shutdown ) {
|
||||||
/* shutdown signal */
|
/* shutdown signal */
|
||||||
@@ -860,8 +859,8 @@ static void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &
|
|||||||
|
|
||||||
#ifdef HAVE_UTEMPTER
|
#ifdef HAVE_UTEMPTER
|
||||||
/* update utmp if has been more than 30 seconds since heard from client */
|
/* update utmp if has been more than 30 seconds since heard from client */
|
||||||
if ( connected_utmp ) {
|
if ( connected_utmp
|
||||||
if ( time_since_remote_state > 30000 ) {
|
&& time_since_remote_state > 30000 ) {
|
||||||
utempter_remove_record( host_fd );
|
utempter_remove_record( host_fd );
|
||||||
|
|
||||||
char tmp[ 64 ];
|
char tmp[ 64 ];
|
||||||
@@ -870,15 +869,12 @@ static void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &
|
|||||||
|
|
||||||
connected_utmp = false;
|
connected_utmp = false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( terminal.set_echo_ack( now ) ) {
|
if ( terminal.set_echo_ack( now ) && !network.shutdown_in_progress() ) {
|
||||||
/* update client with new echo ack */
|
/* update client with new echo ack */
|
||||||
if ( !network.shutdown_in_progress() ) {
|
|
||||||
network.set_current_state( terminal );
|
network.set_current_state( terminal );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( !network.get_remote_state_num()
|
if ( !network.get_remote_state_num()
|
||||||
&& time_since_remote_state >= timeout_if_no_client ) {
|
&& time_since_remote_state >= timeout_if_no_client ) {
|
||||||
|
|||||||
@@ -217,12 +217,10 @@ void STMClient::shutdown( void )
|
|||||||
"Please verify that UDP port %s is not firewalled and can reach the server.\n\n"
|
"Please verify that UDP port %s is not firewalled and can reach the server.\n\n"
|
||||||
"(By default, mosh uses a UDP port between 60000 and 61000. The -p option\n"
|
"(By default, mosh uses a UDP port between 60000 and 61000. The -p option\n"
|
||||||
"selects a specific UDP port number.)\n", ip.c_str(), port.c_str(), port.c_str() );
|
"selects a specific UDP port number.)\n", ip.c_str(), port.c_str(), port.c_str() );
|
||||||
} else if ( network ) {
|
} else if ( network && !clean_shutdown ) {
|
||||||
if ( !clean_shutdown ) {
|
|
||||||
fputs( "\n\nmosh did not shut down cleanly. Please note that the\n"
|
fputs( "\n\nmosh did not shut down cleanly. Please note that the\n"
|
||||||
"mosh-server process may still be running on the server.\n", stderr );
|
"mosh-server process may still be running on the server.\n", stderr );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void STMClient::main_init( void )
|
void STMClient::main_init( void )
|
||||||
@@ -481,9 +479,7 @@ bool STMClient::main( void )
|
|||||||
process_network_input();
|
process_network_input();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( sel.read( STDIN_FILENO ) ) {
|
if ( sel.read( STDIN_FILENO ) && !process_user_input( STDIN_FILENO ) ) { /* input from the user needs to be fed to the network */
|
||||||
/* input from the user needs to be fed to the network */
|
|
||||||
if ( !process_user_input( STDIN_FILENO ) ) {
|
|
||||||
if ( !network->has_remote_addr() ) {
|
if ( !network->has_remote_addr() ) {
|
||||||
break;
|
break;
|
||||||
} else if ( !network->shutdown_in_progress() ) {
|
} else if ( !network->shutdown_in_progress() ) {
|
||||||
@@ -491,11 +487,9 @@ bool STMClient::main( void )
|
|||||||
network->start_shutdown();
|
network->start_shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( sel.signal( SIGWINCH ) ) {
|
if ( sel.signal( SIGWINCH ) && !process_resize() ) { /* resize */
|
||||||
/* resize */
|
return false;
|
||||||
if ( !process_resize() ) { return false; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( sel.signal( SIGCONT ) ) {
|
if ( sel.signal( SIGCONT ) ) {
|
||||||
|
|||||||
@@ -552,12 +552,11 @@ void PredictionEngine::cull( const Framebuffer &fb )
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* When predictions come in quickly, slowly take away the glitch trigger. */
|
/* When predictions come in quickly, slowly take away the glitch trigger. */
|
||||||
if ( (now - j->prediction_time) < GLITCH_THRESHOLD ) {
|
if ( now - j->prediction_time < GLITCH_THRESHOLD
|
||||||
if ( (glitch_trigger > 0) && (now - GLITCH_REPAIR_MININTERVAL >= last_quick_confirmation) ) {
|
&& ( glitch_trigger > 0 && now - GLITCH_REPAIR_MININTERVAL >= last_quick_confirmation ) ) {
|
||||||
glitch_trigger--;
|
glitch_trigger--;
|
||||||
last_quick_confirmation = now;
|
last_quick_confirmation = now;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* match rest of row to the actual renditions */
|
/* match rest of row to the actual renditions */
|
||||||
{
|
{
|
||||||
@@ -594,8 +593,8 @@ void PredictionEngine::cull( const Framebuffer &fb )
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* go through cursor predictions */
|
/* go through cursor predictions */
|
||||||
if ( !cursors.empty() ) {
|
if ( !cursors.empty()
|
||||||
if ( cursor().get_validity( fb,
|
&& cursor().get_validity( fb,
|
||||||
local_frame_acked, local_frame_late_acked ) == IncorrectOrExpired ) {
|
local_frame_acked, local_frame_late_acked ) == IncorrectOrExpired ) {
|
||||||
/*
|
/*
|
||||||
fprintf( stderr, "Sadly, we're predicting (%d,%d) vs. (%d,%d) [tau: %ld, expiration_time=%ld, now=%ld]\n",
|
fprintf( stderr, "Sadly, we're predicting (%d,%d) vs. (%d,%d) [tau: %ld, expiration_time=%ld, now=%ld]\n",
|
||||||
@@ -613,7 +612,6 @@ void PredictionEngine::cull( const Framebuffer &fb )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* NB: switching from list to another STL container could break this code.
|
/* NB: switching from list to another STL container could break this code.
|
||||||
So we don't use the cursors_type typedef. */
|
So we don't use the cursors_type typedef. */
|
||||||
@@ -635,7 +633,7 @@ ConditionalOverlayRow & PredictionEngine::get_or_make_row( int row_num, int num_
|
|||||||
|
|
||||||
if ( it != overlays.end() ) {
|
if ( it != overlays.end() ) {
|
||||||
return *it;
|
return *it;
|
||||||
} else {
|
}
|
||||||
/* make row */
|
/* make row */
|
||||||
ConditionalOverlayRow r( row_num );
|
ConditionalOverlayRow r( row_num );
|
||||||
r.overlay_cells.reserve( num_cols );
|
r.overlay_cells.reserve( num_cols );
|
||||||
@@ -645,7 +643,6 @@ ConditionalOverlayRow & PredictionEngine::get_or_make_row( int row_num, int num_
|
|||||||
}
|
}
|
||||||
overlays.push_back( r );
|
overlays.push_back( r );
|
||||||
return overlays.back();
|
return overlays.back();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PredictionEngine::new_user_byte( char the_byte, const Framebuffer &fb )
|
void PredictionEngine::new_user_byte( char the_byte, const Framebuffer &fb )
|
||||||
|
|||||||
@@ -173,12 +173,10 @@ Connection::Socket::Socket( int family )
|
|||||||
/* request explicit congestion notification on received datagrams */
|
/* request explicit congestion notification on received datagrams */
|
||||||
#ifdef HAVE_IP_RECVTOS
|
#ifdef HAVE_IP_RECVTOS
|
||||||
int tosflag = true;
|
int tosflag = true;
|
||||||
if ( setsockopt( _fd, IPPROTO_IP, IP_RECVTOS, &tosflag, sizeof tosflag ) < 0 ) {
|
if ( setsockopt( _fd, IPPROTO_IP, IP_RECVTOS, &tosflag, sizeof tosflag ) < 0
|
||||||
/* FreeBSD disallows this option on IPv6 sockets. */
|
&& family == IPPROTO_IP ) { /* FreeBSD disallows this option on IPv6 sockets. */
|
||||||
if ( family == IPPROTO_IP ) {
|
|
||||||
perror( "setsockopt( IP_RECVTOS )" );
|
perror( "setsockopt( IP_RECVTOS )" );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,11 +109,10 @@ void Emulator::print( const Parser::Print *act )
|
|||||||
this_cell->set_wide( chwidth == 2 ); /* chwidth had better be 1 or 2 here */
|
this_cell->set_wide( chwidth == 2 ); /* chwidth had better be 1 or 2 here */
|
||||||
fb.apply_renditions_to_cell( this_cell );
|
fb.apply_renditions_to_cell( this_cell );
|
||||||
|
|
||||||
if ( chwidth == 2 ) { /* erase overlapped cell */
|
if ( chwidth == 2
|
||||||
if ( fb.ds.get_cursor_col() + 1 < fb.ds.get_width() ) {
|
&& fb.ds.get_cursor_col() + 1 < fb.ds.get_width() ) { /* erase overlapped cell */
|
||||||
fb.reset_cell( fb.get_mutable_cell( fb.ds.get_cursor_row(), fb.ds.get_cursor_col() + 1 ) );
|
fb.reset_cell( fb.get_mutable_cell( fb.ds.get_cursor_row(), fb.ds.get_cursor_col() + 1 ) );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fb.ds.move_col( chwidth, true, true );
|
fb.ds.move_col( chwidth, true, true );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user