void-packages/srcpkgs/mosh/patches/fix-memory-blowup-on-large-paste.patch
Đoàn Trần Công Danh 765e304c4b srcpkgs/m*: convert patches to -Np1
```sh
git grep -l '^patch_args=-Np0' "srcpkgs/$1*/template" |
while read template; do
	for p in ${template%/template}/patches/*; do
		sed -i '
			\,^[+-][+-][+-] /dev/null,b
			/^[*-]\+ [0-9]\+\(,[0-9]\+\)\? [*-]\+$/b
			s,^[*][*][*] ,&a/,
			/^--- /{
				s,\(^--- \)\(./\)*,\1a/,
				s,[.][Oo][Rr][Ii][Gg]\([	/]\),\1,
				s/[.][Oo][Rr][Ii][Gg]$//
				s/[.]patched[.]\([^.]\)/.\1/
				h
			}
			/^+++ -/{
				g
				s/^--- a/+++ b/
				b
			}
			s,\(^+++ \)\(./\)*,\1b/,
		' "$p"
	done
	sed -i '/^patch_args=/d' $template
done
```
2021-06-20 13:17:29 +07:00

35 lines
1.3 KiB
Diff

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
--- a/src/frontend/stmclient.cc
+++ b/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-^ . */