Connection: guard possible direct socket write

fork
mscdex 11 years ago
parent 739236fa7a
commit 0662d18f50

@ -1079,7 +1079,7 @@ Connection.prototype.__defineGetter__('seq', function() {
}); });
Connection.prototype._resUntagged = function(info) { Connection.prototype._resUntagged = function(info) {
var type = info.type, i, len, box, attrs; var type = info.type, i, len, box, attrs, key;
if (type === 'bye') if (type === 'bye')
this._sock.end(); this._sock.end();
@ -1148,7 +1148,7 @@ Connection.prototype._resUntagged = function(info) {
if (!this._box) if (!this._box)
this._createCurrentBox(); this._createCurrentBox();
var key = info.textCode.key.toUpperCase(); key = info.textCode.key.toUpperCase();
if (key === 'UIDVALIDITY') if (key === 'UIDVALIDITY')
this._box.uidvalidity = info.textCode.val; this._box.uidvalidity = info.textCode.val;
@ -1238,7 +1238,7 @@ Connection.prototype._resUntagged = function(info) {
var msg = this._curReq.fetchCache[info.num], var msg = this._curReq.fetchCache[info.num],
keys = Object.keys(info.text), keys = Object.keys(info.text),
keyslen = keys.length, keyslen = keys.length,
toget, msgEmitter, j, key; toget, msgEmitter, j;
if (msg === undefined) { if (msg === undefined) {
// simple case -- no bodies were streamed // simple case -- no bodies were streamed
@ -1564,7 +1564,10 @@ Connection.prototype._enqueue = function(fullcmd, promote, cb) {
// defer until next tick for requests like APPEND and FETCH where access to // defer until next tick for requests like APPEND and FETCH where access to
// the request object is needed immediately after enqueueing // the request object is needed immediately after enqueueing
process.nextTick(function() { self._processQueue(); }); process.nextTick(function() { self._processQueue(); });
} else if (this._curReq && this._curReq.type === 'IDLE') { } else if (this._curReq
&& this._curReq.type === 'IDLE'
&& this._sock
&& this._sock.writable) {
this._idle.enabled = false; this._idle.enabled = false;
this.debug && this.debug('=> DONE'); this.debug && this.debug('=> DONE');
this._sock.write('DONE' + CRLF); this._sock.write('DONE' + CRLF);

Loading…
Cancel
Save