mosh-server: skip redundant resize requests

This might reduce redraw activity on window resize, especially for
slow servers.
This commit is contained in:
John Hood
2015-10-24 16:23:17 -04:00
parent caab7a7d88
commit 1e003b0e76
+6 -1
View File
@@ -656,8 +656,13 @@ static void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &
const Parser::Action *action = us.get_action( i ); const Parser::Action *action = us.get_action( i );
terminal_to_host += terminal.act( action ); terminal_to_host += terminal.act( action );
if ( typeid( *action ) == typeid( Parser::Resize ) ) { if ( typeid( *action ) == typeid( Parser::Resize ) ) {
/* elide consecutive Resize actions */
if ( i < us.size() - 1 &&
typeid( us.get_action( i + 1 ) ) == typeid( Parser::Resize ) ) {
continue;
}
/* tell child process of resize */ /* tell child process of resize */
const Parser::Resize *res = static_cast<const Parser::Resize *>( us.get_action( i ) ); const Parser::Resize *res = static_cast<const Parser::Resize *>( action );
struct winsize window_size; struct winsize window_size;
if ( ioctl( host_fd, TIOCGWINSZ, &window_size ) < 0 ) { if ( ioctl( host_fd, TIOCGWINSZ, &window_size ) < 0 ) {
perror( "ioctl TIOCGWINSZ" ); perror( "ioctl TIOCGWINSZ" );