From d4832ca63a02962a003c22534c60ab089d08a970 Mon Sep 17 00:00:00 2001 From: John Hood Date: Thu, 10 Dec 2015 22:23:29 -0500 Subject: [PATCH] Fix bugs in resize handling. * A resize action could be applied to the framebuffer but discarded before being applied to termios, causing them to be out of sync. * Only every second action was skipped, instead of skipping consecutive resize actions, as intended. Found by inspection, not seen in actual usage or by the window-resize test. --- src/frontend/mosh-server.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/frontend/mosh-server.cc b/src/frontend/mosh-server.cc index 2d90384..fa1b5ef 100644 --- a/src/frontend/mosh-server.cc +++ b/src/frontend/mosh-server.cc @@ -663,12 +663,11 @@ static void serve( int host_fd, Terminal::Complete &terminal, ServerConnection & /* apply userstream to terminal */ for ( size_t i = 0; i < us.size(); i++ ) { const Parser::Action *action = us.get_action( i ); - terminal_to_host += terminal.act( action ); if ( typeid( *action ) == typeid( Parser::Resize ) ) { - /* elide consecutive Resize actions */ - if ( i < us.size() - 1 && + /* apply only the last consecutive Resize action */ + while ( i < us.size() - 1 && typeid( us.get_action( i + 1 ) ) == typeid( Parser::Resize ) ) { - continue; + i++; } /* tell child process of resize */ const Parser::Resize *res = static_cast( action ); @@ -684,6 +683,7 @@ static void serve( int host_fd, Terminal::Complete &terminal, ServerConnection & return; } } + terminal_to_host += terminal.act( action ); } if ( !us.empty() ) {