Bläddra i källkod

PuTTY snapshot bf61af19 (ssh2 conn: don't set mainchan_eof_sent when we didn't - 2018-10-03)

Source commit: adb4173ec9bbb2de4e7873f20cae15c7ac6a8b92
Martin Prikryl 6 år sedan
förälder
incheckning
eb041bc556
3 ändrade filer med 12 tillägg och 8 borttagningar
  1. 1 0
      source/putty/logging.c
  2. 8 5
      source/putty/ssh.c
  3. 3 3
      source/putty/ssh2connection.c

+ 1 - 0
source/putty/logging.c

@@ -153,6 +153,7 @@ static void logfopen_callback(void *vctx, int mode)
 	logwrite(ctx, data, len);
 	bufchain_consume(&ctx->queue, len);
     }
+    logflush(ctx);
 }
 
 /*

+ 8 - 5
source/putty/ssh.c

@@ -69,7 +69,7 @@ struct ssh_tag {
     int term_width, term_height;
 
     bufchain in_raw, out_raw, user_input;
-    int send_outgoing_eof;
+    int pending_close;
     IdempotentCallback ic_out_raw;
 
     PacketLogSettings pls;
@@ -313,8 +313,10 @@ static void ssh_bpp_output_raw_data_callback(void *vctx)
         }
     }
 
-    if (ssh->send_outgoing_eof)
-        sk_write_eof(ssh->s);
+    if (ssh->pending_close) {
+        sk_close(ssh->s);
+        ssh->s = NULL;
+    }
 }
 
 static void ssh_shutdown_internal(Ssh ssh)
@@ -368,9 +370,10 @@ static void ssh_initiate_connection_close(Ssh ssh)
     ssh_shutdown_internal(ssh);
 
     /* Force any remaining queued SSH packets through the BPP, and
-     * schedule sending of EOF on the network socket after them. */
+     * schedule closing the network socket after they go out. */
     ssh_bpp_handle_output(ssh->bpp);
-    ssh->send_outgoing_eof = TRUE;
+    ssh->pending_close = TRUE;
+    queue_idempotent_callback(&ssh->ic_out_raw);
 
     /* Now we expect the other end to close the connection too in
      * response, so arrange that we'll receive notification of that

+ 3 - 3
source/putty/ssh2connection.c

@@ -2267,9 +2267,9 @@ static void mainchan_send_eof(Channel *chan)
          */
         sshfwd_write_eof(mc->sc);
         ppl_logevent(("Sent EOF message"));
+        s->mainchan_eof_sent = TRUE;
+        s->want_user_input = FALSE;      /* now stop reading from stdin */
     }
-    s->mainchan_eof_sent = TRUE;
-    s->want_user_input = FALSE;      /* now stop reading from stdin */
 }
 
 static void mainchan_set_input_wanted(Channel *chan, int wanted)
@@ -2480,7 +2480,7 @@ static int ssh2_connection_want_user_input(PacketProtocolLayer *ppl)
 {
     struct ssh2_connection_state *s =
         FROMFIELD(ppl, struct ssh2_connection_state, ppl);
-    return s->want_user_input;
+    return s->mainchan_ready && s->want_user_input;
 }
 
 static void ssh2_connection_got_user_input(PacketProtocolLayer *ppl)