Collapse nested conditionals.
This commit is contained in:
+14
-18
@@ -826,12 +826,11 @@ static void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &
|
||||
fprintf( stderr, "Network idle for %llu seconds.\n",
|
||||
static_cast<unsigned long long>( time_since_remote_state / 1000 ) );
|
||||
}
|
||||
if ( sel.signal( SIGUSR1 ) ) {
|
||||
if ( !network_signaled_timeout_ms || network_signaled_timeout_ms <= time_since_remote_state ) {
|
||||
idle_shutdown = true;
|
||||
fprintf( stderr, "Network idle for %llu seconds when SIGUSR1 received\n",
|
||||
static_cast<unsigned long long>( time_since_remote_state / 1000 ) );
|
||||
}
|
||||
if ( sel.signal( SIGUSR1 )
|
||||
&& ( !network_signaled_timeout_ms || network_signaled_timeout_ms <= time_since_remote_state ) ) {
|
||||
idle_shutdown = true;
|
||||
fprintf( stderr, "Network idle for %llu seconds when SIGUSR1 received\n",
|
||||
static_cast<unsigned long long>( time_since_remote_state / 1000 ) );
|
||||
}
|
||||
|
||||
if ( sel.any_signal() || idle_shutdown ) {
|
||||
@@ -860,24 +859,21 @@ static void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &
|
||||
|
||||
#ifdef HAVE_UTEMPTER
|
||||
/* update utmp if has been more than 30 seconds since heard from client */
|
||||
if ( connected_utmp ) {
|
||||
if ( time_since_remote_state > 30000 ) {
|
||||
utempter_remove_record( host_fd );
|
||||
if ( connected_utmp
|
||||
&& time_since_remote_state > 30000 ) {
|
||||
utempter_remove_record( host_fd );
|
||||
|
||||
char tmp[ 64 ];
|
||||
snprintf( tmp, 64, "mosh [%d]", getpid() );
|
||||
utempter_add_record( host_fd, tmp );
|
||||
char tmp[ 64 ];
|
||||
snprintf( tmp, 64, "mosh [%d]", getpid() );
|
||||
utempter_add_record( host_fd, tmp );
|
||||
|
||||
connected_utmp = false;
|
||||
}
|
||||
connected_utmp = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( terminal.set_echo_ack( now ) ) {
|
||||
if ( terminal.set_echo_ack( now ) && !network.shutdown_in_progress() ) {
|
||||
/* 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()
|
||||
|
||||
+11
-17
@@ -217,11 +217,9 @@ void STMClient::shutdown( void )
|
||||
"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"
|
||||
"selects a specific UDP port number.)\n", ip.c_str(), port.c_str(), port.c_str() );
|
||||
} else if ( network ) {
|
||||
if ( !clean_shutdown ) {
|
||||
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 );
|
||||
}
|
||||
} else if ( network && !clean_shutdown ) {
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -481,21 +479,17 @@ bool STMClient::main( void )
|
||||
process_network_input();
|
||||
}
|
||||
|
||||
if ( sel.read( STDIN_FILENO ) ) {
|
||||
/* input from the user needs to be fed to the network */
|
||||
if ( !process_user_input( STDIN_FILENO ) ) {
|
||||
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();
|
||||
}
|
||||
if ( sel.read( STDIN_FILENO ) && !process_user_input( STDIN_FILENO ) ) { /* input from the user needs to be fed to the network */
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
if ( sel.signal( SIGWINCH ) ) {
|
||||
/* resize */
|
||||
if ( !process_resize() ) { return false; }
|
||||
if ( sel.signal( SIGWINCH ) && !process_resize() ) { /* resize */
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( sel.signal( SIGCONT ) ) {
|
||||
|
||||
@@ -552,11 +552,10 @@ void PredictionEngine::cull( const Framebuffer &fb )
|
||||
}
|
||||
|
||||
/* When predictions come in quickly, slowly take away the glitch trigger. */
|
||||
if ( (now - j->prediction_time) < GLITCH_THRESHOLD ) {
|
||||
if ( (glitch_trigger > 0) && (now - GLITCH_REPAIR_MININTERVAL >= last_quick_confirmation) ) {
|
||||
glitch_trigger--;
|
||||
last_quick_confirmation = now;
|
||||
}
|
||||
if ( now - j->prediction_time < GLITCH_THRESHOLD
|
||||
&& ( glitch_trigger > 0 && now - GLITCH_REPAIR_MININTERVAL >= last_quick_confirmation ) ) {
|
||||
glitch_trigger--;
|
||||
last_quick_confirmation = now;
|
||||
}
|
||||
|
||||
/* match rest of row to the actual renditions */
|
||||
@@ -594,24 +593,23 @@ void PredictionEngine::cull( const Framebuffer &fb )
|
||||
}
|
||||
|
||||
/* go through cursor predictions */
|
||||
if ( !cursors.empty() ) {
|
||||
if ( cursor().get_validity( fb,
|
||||
if ( !cursors.empty()
|
||||
&& cursor().get_validity( fb,
|
||||
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",
|
||||
cursor().row, cursor().col,
|
||||
fb.ds.get_cursor_row(),
|
||||
fb.ds.get_cursor_col(),
|
||||
cursor().tentative_until_epoch,
|
||||
cursor().expiration_time,
|
||||
now );
|
||||
*/
|
||||
if ( display_preference == Experimental ) {
|
||||
cursors.clear();
|
||||
} else {
|
||||
reset();
|
||||
return;
|
||||
}
|
||||
cursor().row, cursor().col,
|
||||
fb.ds.get_cursor_row(),
|
||||
fb.ds.get_cursor_col(),
|
||||
cursor().tentative_until_epoch,
|
||||
cursor().expiration_time,
|
||||
now );
|
||||
*/
|
||||
if ( display_preference == Experimental ) {
|
||||
cursors.clear();
|
||||
} else {
|
||||
reset();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -635,17 +633,16 @@ ConditionalOverlayRow & PredictionEngine::get_or_make_row( int row_num, int num_
|
||||
|
||||
if ( it != overlays.end() ) {
|
||||
return *it;
|
||||
} else {
|
||||
/* make row */
|
||||
ConditionalOverlayRow r( row_num );
|
||||
r.overlay_cells.reserve( num_cols );
|
||||
for ( int i = 0; i < num_cols; i++ ) {
|
||||
r.overlay_cells.push_back( ConditionalOverlayCell( 0, i, prediction_epoch ) );
|
||||
assert( r.overlay_cells[ i ].col == i );
|
||||
}
|
||||
overlays.push_back( r );
|
||||
return overlays.back();
|
||||
}
|
||||
/* make row */
|
||||
ConditionalOverlayRow r( row_num );
|
||||
r.overlay_cells.reserve( num_cols );
|
||||
for ( int i = 0; i < num_cols; i++ ) {
|
||||
r.overlay_cells.push_back( ConditionalOverlayCell( 0, i, prediction_epoch ) );
|
||||
assert( r.overlay_cells[ i ].col == i );
|
||||
}
|
||||
overlays.push_back( r );
|
||||
return overlays.back();
|
||||
}
|
||||
|
||||
void PredictionEngine::new_user_byte( char the_byte, const Framebuffer &fb )
|
||||
|
||||
Reference in New Issue
Block a user