mosh: adopt, backport fixes

This commit is contained in:
Nathan Owens 2018-12-31 21:19:22 -06:00 committed by Helmut Pozimski
parent e0aa87fc6c
commit f2fa39f198
3 changed files with 160 additions and 3 deletions

View file

@ -0,0 +1,35 @@
From 91de8901f5da04bc2abba3242164b0a330764d49 Mon Sep 17 00:00:00 2001
From: John Hood <cgull@glup.org>
Date: Sat, 6 May 2017 23:28:29 -0400
Subject: [PATCH] Don't do prediction on large pastes into mosh-client.
Fixes #482, memory use blowup on large pastes. mosh is still pretty slow
about copying pastes through, though.
---
src/frontend/stmclient.cc | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git src/frontend/stmclient.cc src/frontend/stmclient.cc
index 7eff0af3..450d068a 100644
--- src/frontend/stmclient.cc
+++ src/frontend/stmclient.cc
@@ -318,10 +318,18 @@ bool STMClient::process_user_input( int fd )
if ( !network->shutdown_in_progress() ) {
overlays.get_prediction_engine().set_local_frame_sent( network->get_sent_state_last() );
+ /* Don't predict for bulk data. */
+ bool paste = bytes_read > 100;
+ if ( paste ) {
+ overlays.get_prediction_engine().reset();
+ }
+
for ( int i = 0; i < bytes_read; i++ ) {
char the_byte = buf[ i ];
- overlays.get_prediction_engine().new_user_byte( the_byte, local_framebuffer );
+ if ( !paste ) {
+ overlays.get_prediction_engine().new_user_byte( the_byte, local_framebuffer );
+ }
if ( quit_sequence_started ) {
if ( the_byte == '.' ) { /* Quit sequence is Ctrl-^ . */

View file

@ -0,0 +1,122 @@
From 4835dcf5eed93f8dee44e5d1932c38b1cd243d41 Mon Sep 17 00:00:00 2001
From: John Hood <cgull@glup.org>
Date: Mon, 7 Nov 2016 01:00:03 -0500
Subject: [PATCH] Various switch statement fixes.
---
src/frontend/mosh-server.cc | 5 +++--
src/terminal/terminalframebuffer.cc | 1 +
src/terminal/terminalfunctions.cc | 22 ++++++++++++++++------
3 files changed, 20 insertions(+), 8 deletions(-)
diff --git src/frontend/mosh-server.cc src/frontend/mosh-server.cc
index 386fcf92..71acc74d 100644
--- src/frontend/mosh-server.cc
+++ src/frontend/mosh-server.cc
@@ -250,8 +250,9 @@ int main( int argc, char *argv[] )
locale_vars.push_back( string( optarg ) );
break;
default:
- print_usage( stderr, argv[ 0 ] );
/* don't die on unknown options */
+ print_usage( stderr, argv[ 0 ] );
+ break;
}
}
} else if ( argc == 1 ) {
@@ -658,7 +659,7 @@ static void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &
bool child_released = false;
- while ( 1 ) {
+ while ( true ) {
try {
static const uint64_t timeout_if_no_client = 60000;
int timeout = INT_MAX;
diff --git src/terminal/terminalframebuffer.cc src/terminal/terminalframebuffer.cc
index a724afa6..93a31553 100644
--- src/terminal/terminalframebuffer.cc
+++ src/terminal/terminalframebuffer.cc
@@ -512,6 +512,7 @@ void Renditions::set_rendition( color_type num )
case 5: case 25: set_attribute(blink, value); break;
case 7: case 27: set_attribute(inverse, value); break;
case 8: case 28: set_attribute(invisible, value); break;
+ default: assert(false);
}
}
diff --git src/terminal/terminalfunctions.cc src/terminal/terminalfunctions.cc
index 87cb95c4..a0210e34 100644
--- src/terminal/terminalfunctions.cc
+++ src/terminal/terminalfunctions.cc
@@ -64,6 +64,8 @@ static void CSI_EL( Framebuffer *fb, Dispatcher *dispatch )
case 2: /* all of line */
fb->reset_row( fb->get_mutable_row( -1 ) );
break;
+ default:
+ break;
}
}
@@ -89,6 +91,8 @@ static void CSI_ED( Framebuffer *fb, Dispatcher *dispatch ) {
fb->reset_row( fb->get_mutable_row( y ) );
}
break;
+ default:
+ break;
}
}
@@ -114,10 +118,11 @@ static void CSI_cursormove( Framebuffer *fb, Dispatcher *dispatch )
break;
case 'H':
case 'f':
- int x = dispatch->getparam( 0, 1 );
- int y = dispatch->getparam( 1, 1 );
- fb->ds.move_row( x - 1 );
- fb->ds.move_col( y - 1 );
+ fb->ds.move_row( dispatch->getparam( 0, 1 ) - 1 );
+ fb->ds.move_col( dispatch->getparam( 1, 1 ) - 1 );
+ break;
+ default:
+ break;
}
}
@@ -261,6 +266,8 @@ static void CSI_TBC( Framebuffer *fb, Dispatcher *dispatch )
fb->ds.clear_tab( x );
}
break;
+ default:
+ break;
}
}
@@ -295,6 +302,8 @@ static bool *get_DEC_mode( int param, Framebuffer *fb ) {
return &(fb->ds.mouse_alternate_scroll);
case 2004: /* bracketed paste */
return &(fb->ds.bracketed_paste);
+ default:
+ break;
}
return NULL;
}
@@ -340,8 +349,7 @@ static Function func_CSI_DECSM( CSI, "?h", CSI_DECSM, false );
static Function func_CSI_DECRM( CSI, "?l", CSI_DECRM, false );
static bool *get_ANSI_mode( int param, Framebuffer *fb ) {
- switch ( param ) {
- case 4: /* insert/replace mode */
+ if ( param == 4 ) { /* insert/replace mode */
return &(fb->ds.insert_mode);
}
return NULL;
@@ -452,6 +460,8 @@ static void CSI_DSR( Framebuffer *fb, Dispatcher *dispatch )
fb->ds.get_cursor_col() + 1 );
dispatch->terminal_to_host.append( cpr );
break;
+ default:
+ break;
}
}

View file

@ -1,14 +1,14 @@
# Template file for 'mosh'
pkgname=mosh
version=1.3.2
revision=10
revision=11
build_style=gnu-configure
hostmakedepends="pkg-config protobuf-devel"
makedepends="ncurses-devel protobuf-devel libutempter-devel libressl-devel"
depends="perl-IO-Tty"
short_desc="Mobile shell, remote terminal application that allows roaming"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
license="GPL-3"
maintainer="Nathan Owens <ndowens04@gmail.com>"
license="GPL-3.0-or-later"
homepage="https://mosh.org/"
distfiles="https://mosh.org/mosh-${version}.tar.gz"
checksum=da600573dfa827d88ce114e0fed30210689381bbdcff543c931e4d6a2e851216