[ARVADOS-WORKBENCH2] updated: 2.2.1-85-g0ccf1750

Git user git at public.arvados.org
Mon Sep 20 21:32:24 UTC 2021


Summary of changes:
 public/webshell/index.html        |  4 ++--
 public/webshell/shell_in_a_box.js | 18 ++++++++++--------
 2 files changed, 12 insertions(+), 10 deletions(-)

       via  0ccf1750b4143223e729fc3212b5e4b0a447b420 (commit)
      from  405bb231a0cb75e41fdcdf22ce268fe592a2edfd (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 0ccf1750b4143223e729fc3212b5e4b0a447b420
Author: Stephen Smith <stephen at curii.com>
Date:   Mon Sep 20 17:31:31 2021 -0400

    17229: Patch shellinabox to cleanly close instead of sending cancel+eof
    
    Arvados-DCO-1.1-Signed-off-by: Stephen Smith <stephen at curii.com>

diff --git a/public/webshell/index.html b/public/webshell/index.html
index 42ef9a44..028664c4 100644
--- a/public/webshell/index.html
+++ b/public/webshell/index.html
@@ -59,8 +59,8 @@
         var lastTime = localStorage.getItem('lastActiveTimestamp');
         if (currentTime - lastTime > idleTimeoutMs) {
           //logout
-          sh.sendKeys('03'); // Ctrl + c
-          sh.sendKeys('04'); // Ctrl + d
+          sh.reset();
+          sh.sessionClosed();
           document.body.onmousemove = undefined;
           document.body.onkeydown = undefined;
         } else {
diff --git a/public/webshell/shell_in_a_box.js b/public/webshell/shell_in_a_box.js
index 1002f7a9..c258b5d7 100644
--- a/public/webshell/shell_in_a_box.js
+++ b/public/webshell/shell_in_a_box.js
@@ -122,7 +122,7 @@ function ShellInABox(url, container) {
   // Chrome never realizes that the page has loaded.
   setTimeout(function(shellInABox) {
                return function() {
-                 shellInABox.sendRequest();
+                 shellInABox.sendRequest(true);
                };
              }(this), 1);
 };
@@ -137,6 +137,7 @@ ShellInABox.prototype.sessionClosed = function() {
         this.vt100('\r\n');
       }
       this.vt100('Session closed.');
+      this.currentRequest.abort();
     }
     // Revealing the "reconnect" button is commented out until we hook
     // up the username+token auto-login mechanism to the new session:
@@ -161,14 +162,14 @@ ShellInABox.prototype.reconnect = function() {
         this.pendingKeys     = '';
         this.keysInFlight    = false;
         this.reset(true);
-        this.sendRequest();
+        this.sendRequest(true);
       }
     }
   }
   return false;
 };
 
-ShellInABox.prototype.sendRequest = function(request) {
+ShellInABox.prototype.sendRequest = function(init = false, request) {
   if (request == undefined) {
     request                  = new XMLHttpRequest();
   }
@@ -185,7 +186,7 @@ ShellInABox.prototype.sendRequest = function(request) {
   request.onreadystatechange = function(shellInABox) {
     return function() {
              try {
-               return shellInABox.onReadyStateChange(request);
+               return shellInABox.onReadyStateChange(request, init);
              } catch (e) {
                shellInABox.sessionClosed();
              }
@@ -193,10 +194,11 @@ ShellInABox.prototype.sendRequest = function(request) {
     }(this);
   ShellInABox.lastRequestSent = Date.now();
   request.send(content);
+  this.currentRequest = request;
 };
 
-ShellInABox.prototype.onReadyStateChange = function(request) {
-  if (request.readyState == 4 /* XHR_LOADED */) {
+ShellInABox.prototype.onReadyStateChange = function(request, init) {
+  if (request.readyState == 4 /* XHR_LOADED */ && (this.connected || init)) {
     if (request.status == 200) {
       this.connected = true;
       var response   = eval('(' + request.responseText + ')');
@@ -209,12 +211,12 @@ ShellInABox.prototype.onReadyStateChange = function(request) {
         this.sessionClosed();
       } else {
         this.session = response.session;
-        this.sendRequest(request);
+        this.sendRequest(false, request);
       }
     } else if (request.status == 0) {
         if (ShellInABox.lastRequestSent + 2000 < Date.now()) {
             // Timeout, try again
-            this.sendRequest(request);
+            this.sendRequest(false, request);
         } else {
             this.vt100('\r\n\r\nRequest failed.');
             this.sessionClosed();

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list