[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2-4' - 2 commits - loleaflet/js

Michael Meeks (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 9 10:47:59 UTC 2020


 loleaflet/js/global.js |   50 ++++++++++++++++++++++++++-----------------------
 1 file changed, 27 insertions(+), 23 deletions(-)

New commits:
commit e77e689e10bbb86ee52f357e70947f6142bd886b
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Tue Jun 9 11:29:11 2020 +0100
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Tue Jun 9 12:47:33 2020 +0200

    Proxy: detect un-responsive sockets & close after 30secs.
    
    Also:
    + fix double poll timer in error
    + remove & rename incorrect interval timer names
    
    Change-Id: Idfae44c0a388312b248c78fc9ad04fe3725990b6
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/95910
    Tested-by: Jenkins
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/loleaflet/js/global.js b/loleaflet/js/global.js
index c6590389b..6a0bd23df 100644
--- a/loleaflet/js/global.js
+++ b/loleaflet/js/global.js
@@ -350,14 +350,16 @@
 		};
 		this.sendQueue = '';
 		this._signalErrorClose = function() {
+			clearInterval(this.pollInterval);
+			clearTimeout(this.delaySession);
+			this.pollInterval = undefined;
+			this.delaySession = undefined;
+
 			if (that.readyState < 3)
 			{
 				this.onerror();
 				this.onclose();
 			}
-			clearInterval(this.waitInterval);
-			clearTimeout(this.delaySession);
-			this.waitInterval = undefined;
 			this.sessionId = 'open';
 			this.inSerial = 0;
 			this.outSerial = 0;
@@ -365,9 +367,14 @@
 			this.openInflight = 0;
 			this.readyState = 3; // CLOSED
 		};
+		// For those who think that long-running sockets are a
+		// better way to wait: you're so right. However, each
+		// consumes a scarce server worker thread while it waits,
+		// so ... back in the real world:
 		this._setPollInterval = function(intervalMs) {
-			clearInterval(that.pollInterval);
-			that.pollInterval = setInterval(that.doSend, intervalMs);
+			clearInterval(this.pollInterval);
+			if (this.readyState === 1)
+				this.pollInterval = setInterval(this.doSend, intervalMs);
 		},
 		this.doSend = function () {
 			if (that.sessionId === 'open')
@@ -388,6 +395,11 @@
 					console.debug('High latency connection - too much in-flight, throttling to ' + that.curPollMs + ' ms.');
 					that._setPollInterval(that.curPollMs);
 				}
+				else if (performance.now() - that.lastDataTimestamp > 30 * 1000)
+				{
+					console.debug('Close connection after no response for 30secs');
+					that._signalErrorClose();
+				}
 				else
 					console.debug('High latency connection - too much in-flight, pausing.');
 				return;
@@ -490,12 +502,7 @@
 					that.sessionId = this.responseText;
 					that.readyState = 1;
 					that.onopen();
-
-					// For those who think that long-running sockets are a
-					// better way to wait: you're so right. However, each
-					// consumes a scarce server worker thread while it waits,
-					// so ... back in the real world:
-					that.pollInterval = setInterval(that.doSend, that.curPollMs);
+					that._setPollInterval(that.curPollMs);
 				}
 			});
 			req.addEventListener('loadend', function() {
@@ -540,9 +547,9 @@
 			console.debug('proxy: close socket');
 			this.readyState = 3;
 			this.onclose();
-			clearInterval(this.waitInterval);
+			clearInterval(this.pollInterval);
 			clearTimeout(this.delaySession);
-			this.waitInterval = undefined;
+			this.pollInterval = undefined;
 			if (oldState === 1) // was open
 				this.sendCloseMsg(this.unloading);
 			this.sessionId = 'open';
commit 80d8018b40ff893ff8d2cb0865dd827455506a1a
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Tue Jun 9 10:44:30 2020 +0100
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Tue Jun 9 12:47:28 2020 +0200

    Proxy: don't implement a magic re-connecting socket.
    
    Websockets don't magically re-connect, so we shouldn't either.
    Also avoid starting our send interval timer until we've opened
    to simplify.
    
    Change-Id: Id71049da2d4b4d0ac2f38a3d7410f2446d04f0b1
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/95906
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Tested-by: Jenkins
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/loleaflet/js/global.js b/loleaflet/js/global.js
index 0cafa649c..c6590389b 100644
--- a/loleaflet/js/global.js
+++ b/loleaflet/js/global.js
@@ -354,15 +354,15 @@
 			{
 				this.onerror();
 				this.onclose();
-				clearInterval(this.waitInterval);
-				clearTimeout(this.delaySession);
-				this.waitInterval = undefined;
-				this.sessionId = 'open';
-				this.inSerial = 0;
-				this.outSerial = 0;
-				this.msgInflight = 0;
-				this.openInflight = 0;
 			}
+			clearInterval(this.waitInterval);
+			clearTimeout(this.delaySession);
+			this.waitInterval = undefined;
+			this.sessionId = 'open';
+			this.inSerial = 0;
+			this.outSerial = 0;
+			this.msgInflight = 0;
+			this.openInflight = 0;
 			this.readyState = 3; // CLOSED
 		};
 		this._setPollInterval = function(intervalMs) {
@@ -373,10 +373,7 @@
 			if (that.sessionId === 'open')
 			{
 				if (that.readyState === 3)
-				{
-					console.debug('Session closed, opening a new one.');
-					that.getSessionId();
-				}
+					console.debug('Error: sending on closed socket');
 				return;
 			}
 
@@ -488,11 +485,17 @@
 					console.debug('Error: failed to fetch session id! error: ' + this.status);
 					that._signalErrorClose();
 				}
-				else
+				else // we connected - lets get going ...
 				{
 					that.sessionId = this.responseText;
 					that.readyState = 1;
 					that.onopen();
+
+					// For those who think that long-running sockets are a
+					// better way to wait: you're so right. However, each
+					// consumes a scarce server worker thread while it waits,
+					// so ... back in the real world:
+					that.pollInterval = setInterval(that.doSend, that.curPollMs);
 				}
 			});
 			req.addEventListener('loadend', function() {
@@ -555,12 +558,6 @@
 
 		// queue fetch of session id.
 		this.getSessionId();
-
-		// For those who think that long-running sockets are a
-		// better way to wait: you're so right. However, each
-		// consumes a scarce server worker thread while it waits,
-		// so ... back in the real world:
-		this.pollInterval = setInterval(this.doSend, this.curPollMs);
 	};
 
 	if (global.socketProxy)


More information about the Libreoffice-commits mailing list