YUKI Hiroshi
null+****@clear*****
Tue Mar 18 19:03:25 JST 2014
YUKI Hiroshi 2014-03-18 19:03:25 +0900 (Tue, 18 Mar 2014) New Revision: 406372ddf6a335a436ffef79833919a5c5351f5f https://github.com/droonga/express-droonga/commit/406372ddf6a335a436ffef79833919a5c5351f5f Message: Restart receiver for every 100 receiving or 100 sendings Modified files: lib/droonga-protocol/connection.js Modified: lib/droonga-protocol/connection.js (+9 -6) =================================================================== --- lib/droonga-protocol/connection.js 2014-03-18 18:50:57 +0900 (f1bb559) +++ lib/droonga-protocol/connection.js 2014-03-18 19:03:25 +0900 (de9a008) @@ -54,6 +54,7 @@ Connection.prototype._init = function() { this._params.defaultDataset || ''; this._receiverMaxAge = this._params.receiverMaxAge; + this._shouldRestartReceiver = (this._receiverMaxAge && this._receiverMaxAge > 0); this._initSender(); this._initReceiver(); }; @@ -73,7 +74,8 @@ Connection.prototype._initSender = function(wait) { }; Connection.prototype._initReceiver = function() { - this._receiverAge = 0; + this._receiveCount = 0; + this._sendCount = 0; if (!this._receiver) { this.receiveHostName = process.env.DROONGA_ENGINE_RECEIVE_HOST || this._params.receiveHostName || @@ -102,11 +104,8 @@ function isSuccess(code) { } Connection.prototype._handleMessage = function(envelope) { - if (this._receiverMaxAge && this._receiverMaxAge > 0) { - this._receiverAge++; - if (this._receiverAge >= this._receiverMaxAge) { - this._initReceiver(); - } + if (this._shouldRestartReceiver && ++this._receiveCount >= this._receiverMaxAge) { + this._initReceiver(); } var inReplyTo = envelope.inReplyTo; if (inReplyTo) { @@ -180,6 +179,10 @@ Connection.prototype.emitMessage = function(type, body, callback, options) { body: body }; if (callback) { + if (this._shouldRestartReceiver && ++this._sendCount >= this._receiverMaxAge) { + this._initReceiver(); + } + envelope.replyTo = from; var event = 'reply:' + id; -------------- next part -------------- HTML����������������������������...Download