From b8690a4307c9b4e2a355c7d686673124c9db1aa5 Mon Sep 17 00:00:00 2001 From: Brandon Hinshaw Date: Fri, 31 Mar 2017 02:04:56 -0700 Subject: [PATCH 1/2] Fix write after closes, and clean up session references --- server.js | 4 +++- src/Session.js | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index 0631c5d..ea22474 100644 --- a/server.js +++ b/server.js @@ -128,8 +128,10 @@ Server.prototype.onConnect = function (socket) { }); socket.on('close', function () { log.info('Client disconnected: ' + addr); - if (s) + if (s) { self._sessions.remove(s); + s = null; + } }); socket.once('data', function (data) { diff --git a/src/Session.js b/src/Session.js index 46d5ec7..02d1611 100644 --- a/src/Session.js +++ b/src/Session.js @@ -43,7 +43,8 @@ module.exports = Session; Session.prototype.send = function(method, data) { var packet = JSON.stringify({method:method,data:data}); - this._socket.write(packet+'\r\n'); + if (!this._socket.destroyed) + this._socket.write(packet+'\r\n'); //log.info('S->C: ' + packet); }; From e56f2742be94292afbac09274c148b956a408b6f Mon Sep 17 00:00:00 2001 From: Brandon Hinshaw Date: Fri, 31 Mar 2017 02:15:56 -0700 Subject: [PATCH 2/2] Disable userlist in test config --- test/test-config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-config.js b/test/test-config.js index 237780c..7c4ea59 100644 --- a/test/test-config.js +++ b/test/test-config.js @@ -95,6 +95,6 @@ module.exports = { /* intervalPlugins are called in intervals specified in seconds. */ intervalPlugins: [ - { plugin: "janus-mysql-userlist-official", interval: 5 } + //{ plugin: "janus-mysql-userlist-official", interval: 5 } ], };