Don't clear connection timer until greeting is received

fork
Brian White 12 years ago
parent 1bc39932df
commit 4e61905378

@ -129,7 +129,6 @@ ImapConnection.prototype.connect = function(loginCb) {
state.conn.cleartext = state.conn;
state.conn.on('connect', function() {
clearTimeout(state.tmrConn);
state.connected = true;
state.authenticated = false;
self.debug&&self.debug('[connection] Connected to host.');
@ -488,6 +487,7 @@ ImapConnection.prototype.connect = function(loginCb) {
var code = m[2];
if (state.status === STATES.NOAUTH) {
if (!state.isReady) {
clearTimeout(state.tmrConn);
state.isReady = true;
state.conn.emit('ready');
}
@ -666,8 +666,11 @@ ImapConnection.prototype.connect = function(loginCb) {
state.conn.cleartext.on('data', ondata);
state.conn.connect(this._options.port, this._options.host);
state.tmrConn = setTimeout(this._fnTmrConn.bind(this, loginCb),
this._options.connTimeout);
state.tmrConn = setTimeout(function() {
state.conn.destroy();
loginCb(new Error('Connection timed out'));
}, this._options.connTimeout);
};
ImapConnection.prototype.isAuthenticated = function() {
@ -1274,11 +1277,6 @@ ImapConnection.prototype.__defineGetter__('seq', function() {
// Private/Internal Functions
ImapConnection.prototype._fnTmrConn = function(loginCb) {
loginCb(new Error('Connection timed out'));
this._state.conn.destroy();
};
ImapConnection.prototype._serverSupports = function(capability) {
return (this.capabilities.indexOf(capability) > -1);
};

Loading…
Cancel
Save