summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklós Fazekas <mfazekas@szemafor.com>2018-05-24 10:04:47 +0200
committerGitHub <noreply@github.com>2018-05-24 10:04:47 +0200
commit736b26c5347a069a5bd63f4db01d39b96e4e1303 (patch)
tree75eab03fa7833ca0ab0c4f0d8dc168fcaca4fee9
parentb6a22b5f996cc0a199acaf9d0ee048bad3891d05 (diff)
parent547796e2117ce52807ea38b2dbea3d7c5c4db00e (diff)
downloadnet-ssh-736b26c5347a069a5bd63f4db01d39b96e4e1303.tar.gz
Merge pull request #599 from mfazekas/fix-4gb-scp
Don't keep increasing local_window_size beyond limits
-rw-r--r--lib/net/ssh/connection/channel.rb17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/net/ssh/connection/channel.rb b/lib/net/ssh/connection/channel.rb
index 0ee83f8..375c8c9 100644
--- a/lib/net/ssh/connection/channel.rb
+++ b/lib/net/ssh/connection/channel.rb
@@ -629,15 +629,18 @@ module Net
error { "channel success received with no pending request to handle it (bug?)" }
end
end
-
+
private
-
+
# Runs the SSH event loop until the remote confirmed channel open
# experimental api
def wait_until_open_confirmed
connection.loop { !remote_id }
end
-
+
+ LOCAL_WINDOW_SIZE_INCREMENT = 0x20000
+ GOOD_LOCAL_MAXIUMUM_WINDOW_SIZE = 10 * LOCAL_WINDOW_SIZE_INCREMENT
+
# Updates the local window size by the given amount. If the window
# size drops to less than half of the local maximum (an arbitrary
# threshold), a CHANNEL_WINDOW_ADJUST message will be sent to the
@@ -646,12 +649,12 @@ module Net
@local_window_size -= size
if local_window_size < local_maximum_window_size / 2
connection.send_message(Buffer.from(:byte, CHANNEL_WINDOW_ADJUST,
- :long, remote_id, :long, 0x20000))
- @local_window_size += 0x20000
- @local_maximum_window_size += 0x20000
+ :long, remote_id, :long, LOCAL_WINDOW_SIZE_INCREMENT))
+ @local_window_size += LOCAL_WINDOW_SIZE_INCREMENT
+ @local_maximum_window_size += LOCAL_WINDOW_SIZE_INCREMENT if @local_maximum_window_size < @local_window_size || @local_maximum_window_size < GOOD_LOCAL_MAXIUMUM_WINDOW_SIZE
end
end
-
+
# Gets an +Array+ of local environment variables in the remote process'
# environment.
# A variable name can either be described by a +Regexp+ or +String+.