guard against duplicate DONE commands

fork
mscdex 11 years ago
parent 1e020b47c1
commit 26c6a7827c

@ -39,7 +39,8 @@ var CRLF = '\r\n',
// extension constants
var IDLE_NONE = 1,
IDLE_WAIT = 2,
IDLE_IDLING = 3;
IDLE_IDLING = 3,
IDLE_DONE = 4;
function ImapConnection(options) {
if (!(this instanceof ImapConnection))
@ -763,9 +764,10 @@ ImapConnection.prototype.connect = function(loginCb) {
if (state.isIdle) {
if (state.ext.idle.state === IDLE_IDLING) {
var timeDiff = Date.now() - state.ext.idle.timeStarted;
if (timeDiff >= state.ext.idle.MAX_WAIT)
if (timeDiff >= state.ext.idle.MAX_WAIT) {
state.ext.idle.state = IDLE_DONE;
self._send('DONE');
else
} else
state.tmrKeepalive = setTimeout(idleHandler, state.tmoKeepalive);
} else if (!self.serverSupports('IDLE'))
doKeepalive();
@ -1578,8 +1580,10 @@ ImapConnection.prototype._send = function(cmdstr, cb) {
}
if (idle.state !== IDLE_NONE && cmdstr !== 'DONE') {
if (cmdstr !== undefined)
if (cmdstr !== undefined && idle.state !== IDLE_DONE) {
idle.state = IDLE_DONE;
this._send('DONE');
}
return;
}

Loading…
Cancel
Save