From 511616a973041b2893c91f0ae7344c97509d6af0 Mon Sep 17 00:00:00 2001 From: deuce <> Date: Thu, 14 Jan 2016 02:08:14 +0000 Subject: [PATCH] Add session timeout support. --- exec/load/binkp.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/exec/load/binkp.js b/exec/load/binkp.js index f7394ccefd..c4ee18f0fb 100644 --- a/exec/load/binkp.js +++ b/exec/load/binkp.js @@ -369,6 +369,7 @@ BinkP.prototype.session = function() var ver; var args; var size; + var last = Date.now(); // Session set up, we're good to go! outer: @@ -377,6 +378,7 @@ BinkP.prototype.session = function() // skipping files. pkt = this.recvFrame(this.senteob ? this.timeout : 0); if (pkt !== undefined && pkt !== this.partialFrame && pkt !== null) { + last = Date.now(); if (pkt.is_cmd) { cmd_switch: switch(pkt.command) { @@ -537,12 +539,16 @@ BinkP.prototype.session = function() } } if (this.sending !== undefined) { - this.sendData(this.sending.read(32767)); + if(this.sendData(this.sending.read(32767))) + last = Date.now(); if (this.eof || this.sending.position >= this.sending.length) { this.sending.close(); this.sending = undefined; } } + + if ((last + this.timeout)*1000 < Date.now()) + this.sendCmd(this.command.M_ERR, "Timeout exceeded!"); } this.close(); -- GitLab