From 9ee0f51818f707ea6195f74edb13bbbd8e1375ce Mon Sep 17 00:00:00 2001 From: Brian White Date: Sat, 5 Oct 2013 01:02:14 -0400 Subject: [PATCH] connection: add additional guards for idle changing --- lib/Connection.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/Connection.js b/lib/Connection.js index 73a7e2e..23db60b 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -205,7 +205,8 @@ Connection.prototype.connect = function() { if (self._queue.length === 0 && self._config.keepalive - && self.state === 'authenticated') { + && self.state === 'authenticated' + && !self._idle.enabled) { self._idle.enabled = true; self._doKeepaliveTimer(true); } @@ -1368,7 +1369,8 @@ Connection.prototype._resTagged = function(info) { if (this._queue.length === 0 && this._config.keepalive - && this.state === 'authenticated') { + && this.state === 'authenticated' + && !this._idle.enabled) { this._idle.enabled = true; this._doKeepaliveTimer(true); } @@ -1582,7 +1584,8 @@ Connection.prototype._enqueue = function(fullcmd, promote, cb) { } else if (this._curReq && this._curReq.type === 'IDLE' && this._sock - && this._sock.writable) { + && this._sock.writable + && this._idle.enabled) { this._idle.enabled = false; this.debug && this.debug('=> DONE'); this._sock.write('DONE' + CRLF);