Small window-handling tweaks. Set the default big window to 0x7fffffff bytes,
authorben <ben@cda61777-01e9-0310-a592-d414129be87e>
Sun, 5 Aug 2007 14:18:43 +0000 (14:18 +0000)
committerben <ben@cda61777-01e9-0310-a592-d414129be87e>
Sun, 5 Aug 2007 14:18:43 +0000 (14:18 +0000)
and tweak ssh2_set_window() so it can cope with that.  Also arrange to send
a private channel message in simple mode to tell the server that it can safely
use a large window too.

git-svn-id: svn://svn.tartarus.org/sgt/putty@7679 cda61777-01e9-0310-a592-d414129be87e

ssh.c

diff --git a/ssh.c b/ssh.c
index 51b5320..1127c5c 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -472,13 +472,13 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen,
  *    channels.
  *
  *  - OUR_V2_BIGWIN is the window size we advertise for the only
- *    channel in a simple connection.
+ *    channel in a simple connection.  It must be <= INT_MAX.
  */
 
 #define SSH1_BUFFER_LIMIT 32768
 #define SSH_MAX_BACKLOG 32768
 #define OUR_V2_WINSIZE 16384
-#define OUR_V2_BIGWIN 0x10000000
+#define OUR_V2_BIGWIN 0x7fffffff
 #define OUR_V2_MAXPKT 0x4000UL
 
 /* Maximum length of passwords/passphrases (arbitrary) */
@@ -6191,7 +6191,7 @@ static void ssh2_set_window(struct ssh_channel *c, unsigned newwin)
      *
      * "Significant" is arbitrarily defined as half the window size.
      */
-    if (newwin >= c->v.v2.locwindow * 2) {
+    if (newwin / 2 >= c->v.v2.locwindow) {
        struct Packet *pktout;
 
        pktout = ssh2_pkt_init(SSH2_MSG_CHANNEL_WINDOW_ADJUST);
@@ -8060,6 +8060,20 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen,
     ssh->packet_dispatch[SSH2_MSG_CHANNEL_OPEN] =
        ssh2_msg_channel_open;
 
+    if (ssh->cfg.ssh_simple) {
+       /*
+        * This message indicates to the server that we promise
+        * not to try to run any other channel in parallel with
+        * this one, so it's safe for it to advertise a very large
+        * window and leave the flow control to TCP.
+        */
+       s->pktout = ssh2_pkt_init(SSH2_MSG_CHANNEL_REQUEST);
+       ssh2_pkt_adduint32(s->pktout, ssh->mainchan->remoteid);
+       ssh2_pkt_addstring(s->pktout, "simple@putty.projects.tartarus.org");
+       ssh2_pkt_addbool(s->pktout, 0); /* no reply */
+       ssh2_pkt_send(ssh, s->pktout);
+    }
+
     /*
      * Potentially enable X11 forwarding.
      */