From f2a696385f46aa085729a0e43a8824bf27abe91a Mon Sep 17 00:00:00 2001 From: zengjiwen <308719290@qq.com> Date: Sun, 4 Sep 2022 23:41:26 +0800 Subject: [PATCH 1/3] dictionary bug fix --- lib/components/dictionary.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/components/dictionary.js b/lib/components/dictionary.js index 47e8e2844..c0ce57619 100644 --- a/lib/components/dictionary.js +++ b/lib/components/dictionary.js @@ -31,7 +31,7 @@ var pro = Component.prototype; pro.name = '__dictionary__'; pro.start = function(cb) { - var servers = this.app.get('servers'); + var servers = this.app.serverTypeMaps; var routes = []; //Load all the handler files From 24e8efb4946fed8efea905aa09fe6956887c9e4a Mon Sep 17 00:00:00 2001 From: zengjiwen <308719290@qq.com> Date: Thu, 10 Aug 2023 16:46:08 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E6=AD=A7=E4=B9=89=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/connectors/commands/heartbeat.js | 18 +++++++++--------- lib/connectors/udpsocket.js | 16 +++++++--------- lib/modules/console.js | 4 ++-- lib/util/constants.js | 3 ++- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/lib/connectors/commands/heartbeat.js b/lib/connectors/commands/heartbeat.js index 213ce4efc..3c8b69470 100644 --- a/lib/connectors/commands/heartbeat.js +++ b/lib/connectors/commands/heartbeat.js @@ -34,15 +34,15 @@ Command.prototype.handle = function(socket) { var self = this; if(!this.clients[socket.id]) { - // clear timers when socket disconnect or error + // clear client and timer when socket disconnect or error this.clients[socket.id] = 1; - socket.once('disconnect', clearTimers.bind(null, this, socket.id)); - socket.once('error', clearTimers.bind(null, this, socket.id)); + socket.once('disconnect', this.clear.bind(this, socket.id)); + socket.once('error', this.clear.bind(this, socket.id)); } // clear timeout timer if(self.disconnectOnTimeout) { - this.clear(socket.id); + this.clearTimers(socket.id); } socket.sendRaw(Package.encode(Package.TYPE_HEARTBEAT)); @@ -55,7 +55,7 @@ Command.prototype.handle = function(socket) { } }; -Command.prototype.clear = function(id) { +Command.prototype.clearTimers = function(id) { var tid = this.timeouts[id]; if(tid) { clearTimeout(tid); @@ -63,11 +63,11 @@ Command.prototype.clear = function(id) { } }; -var clearTimers = function(self, id) { - delete self.clients[id]; - var tid = self.timeouts[id]; +Command.prototype.clear = function(id) { + delete this.clients[id]; + var tid = this.timeouts[id]; if(tid) { clearTimeout(tid); - delete self.timeouts[id]; + delete this.timeouts[id]; } }; diff --git a/lib/connectors/udpsocket.js b/lib/connectors/udpsocket.js index 769f5ae8c..022038bef 100644 --- a/lib/connectors/udpsocket.js +++ b/lib/connectors/udpsocket.js @@ -11,16 +11,14 @@ var ST_WORKING = 2; var ST_CLOSED = 3; var Socket = function(id, socket, peer) { - EventEmitter.call(this); - + EventEmitter.call(this); + this.id = id; - this.socket = socket; + this.socket = socket; this.peer = peer; - this.host = peer.address; - this.port = peer.port; - this.remoteAddress = { - ip: this.host, - port: this.port + this.remoteAddress = { + ip: this.peer.address, + port: this.peer.port }; var self = this; @@ -56,7 +54,7 @@ Socket.prototype.send = function(msg) { }; Socket.prototype.sendRaw = function(msg) { - this.socket.send(msg, 0, msg.length, this.port, this.host, function(err, bytes) { + this.socket.send(msg, 0, msg.length, this.remoteAddress.port, this.remoteAddress.ip, function(err, bytes) { if(!!err) { logger.error('send msg to remote with err: %j', err.stack); return; diff --git a/lib/modules/console.js b/lib/modules/console.js index 19a13aa51..78f0dd56a 100644 --- a/lib/modules/console.js +++ b/lib/modules/console.js @@ -117,7 +117,7 @@ var kill = function(app, agent, msg, cb) { var sid, record; var serverIds = []; var count = utils.size(agent.idMap); - var latch = countDownLatch.createCountDownLatch(count, {timeout: Constants.TIME.TIME_WAIT_MASTER_KILL}, function(isTimeout) { + var latch = countDownLatch.createCountDownLatch(count, {timeout: Constants.TIME.TIME_WAIT_ALL_MONITORS_KILL}, function(isTimeout) { if (!isTimeout) { utils.invokeCallback(cb, null, {code: 'ok'}); } else { @@ -125,7 +125,7 @@ var kill = function(app, agent, msg, cb) { } setTimeout(function() { process.exit(-1); - }, Constants.TIME.TIME_WAIT_MONITOR_KILL); + }, Constants.TIME.TIME_WAIT_MASTER_KILL); }); var agentRequestCallback = function(msg) { diff --git a/lib/util/constants.js b/lib/util/constants.js index 99987e45b..48ed83470 100644 --- a/lib/util/constants.js +++ b/lib/util/constants.js @@ -101,8 +101,9 @@ module.exports = { TIME_WAIT_KILL: 5 * 1000, TIME_WAIT_RESTART: 5 * 1000, TIME_WAIT_COUNTDOWN: 10 * 1000, - TIME_WAIT_MASTER_KILL: 2 * 60 * 1000, + TIME_WAIT_MASTER_KILL: 2 * 1000, TIME_WAIT_MONITOR_KILL: 2 * 1000, + TIME_WAIT_ALL_MONITORS_KILL: 2 * 60 * 1000, TIME_WAIT_PING: 30 * 1000, TIME_WAIT_MAX_PING: 5 * 60 * 1000, DEFAULT_UDP_HEARTBEAT_TIME: 20 * 1000, From 48b27b663de0ec40e35fde5fbc0a567f942e86d3 Mon Sep 17 00:00:00 2001 From: zengjiwen <308719290@qq.com> Date: Thu, 10 Aug 2023 17:04:18 +0800 Subject: [PATCH 3/3] Revert "dictionary bug fix" This reverts commit f2a696385f46aa085729a0e43a8824bf27abe91a. --- lib/components/dictionary.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/components/dictionary.js b/lib/components/dictionary.js index c0ce57619..47e8e2844 100644 --- a/lib/components/dictionary.js +++ b/lib/components/dictionary.js @@ -31,7 +31,7 @@ var pro = Component.prototype; pro.name = '__dictionary__'; pro.start = function(cb) { - var servers = this.app.serverTypeMaps; + var servers = this.app.get('servers'); var routes = []; //Load all the handler files