summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2020-06-09 10:44:30 +0100
committerMichael Meeks <michael.meeks@collabora.com>2020-06-09 12:02:56 +0200
commit19b544477e3f425fb55ca6e51be255860c6b13b1 (patch)
tree0a29989f77fdfcda7d953f58354246a932f777fd
parentac17984226dac695fbd68699e168e2332f1ab9c7 (diff)
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@gmail.com> Tested-by: Jenkins Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r--loleaflet/js/global.js35
1 files changed, 16 insertions, 19 deletions
diff --git a/loleaflet/js/global.js b/loleaflet/js/global.js
index d50739193..d033e2f64 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)