From ac71ac0c8f3decf70594503659c727b8ee069e2e Mon Sep 17 00:00:00 2001 From: Brian White Date: Fri, 31 Aug 2012 12:01:46 -0400 Subject: [PATCH] Don't delay processing of extra data until next tick There could be other 'data' events that are waiting to be emitted before the end of the current tick. --- lib/imap.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/imap.js b/lib/imap.js index 92ae6b0..fd46e5a 100644 --- a/lib/imap.js +++ b/lib/imap.js @@ -132,7 +132,7 @@ ImapConnection.prototype.connect = function(loginCb) { state.conn.on('close', function(had_error) { self._reset(); requests = state.requests; - self.debug&&self.debug('[connection] Connection forcefully closed.'); + self.debug&&self.debug('[connection] Connection closed.'); self.emit('close', had_error); }); @@ -249,9 +249,6 @@ ImapConnection.prototype.connect = function(loginCb) { } } - if (b.p < b.length) - process.nextTick(function() { ondata(b); }); - if (ondata.line[0] === '*') { // Untagged server response var isUnsolicited = (requests[0] && requests[0].cmd === 'NOOP') @@ -501,6 +498,8 @@ ImapConnection.prototype.connect = function(loginCb) { ondata.temp = undefined; ondata.streaming = false; ondata.expect = -1; + if (b.p < b.length) + return ondata(b); } else if (ondata.line[0] === 'A' || ondata.line[0] === '+') { var line = ondata.line; ondata.literals = [];