|
@ -447,6 +447,7 @@ function OutgoingMessage() { |
|
|
this._trailer = ''; |
|
|
this._trailer = ''; |
|
|
|
|
|
|
|
|
this.finished = false; |
|
|
this.finished = false; |
|
|
|
|
|
this._hangupClose = false; |
|
|
} |
|
|
} |
|
|
util.inherits(OutgoingMessage, Stream); |
|
|
util.inherits(OutgoingMessage, Stream); |
|
|
|
|
|
|
|
@ -501,12 +502,24 @@ OutgoingMessage.prototype._writeRaw = function(data, encoding) { |
|
|
return this.connection.write(data, encoding); |
|
|
return this.connection.write(data, encoding); |
|
|
} else if (this.connection && this.connection.destroyed) { |
|
|
} else if (this.connection && this.connection.destroyed) { |
|
|
// The socket was destroyed. If we're still trying to write to it,
|
|
|
// The socket was destroyed. If we're still trying to write to it,
|
|
|
// then something bad happened.
|
|
|
// then something bad happened, but it could be just that we haven't
|
|
|
// If we've already raised an error on this message, then just ignore.
|
|
|
// gotten the 'close' event yet.
|
|
|
if (!this._hadError) { |
|
|
//
|
|
|
this.emit('error', createHangUpError()); |
|
|
// In v0.10 and later, this isn't a problem, since ECONNRESET isn't
|
|
|
this._hadError = true; |
|
|
// ignored in the first place. We'll probably emit 'close' on the
|
|
|
|
|
|
// next tick, but just in case it's not coming, set a timeout that
|
|
|
|
|
|
// will emit it for us.
|
|
|
|
|
|
if (!this._hangupClose) { |
|
|
|
|
|
this._hangupClose = true; |
|
|
|
|
|
var socket = this.socket; |
|
|
|
|
|
var timer = setTimeout(function() { |
|
|
|
|
|
socket.emit('close'); |
|
|
|
|
|
}); |
|
|
|
|
|
socket.on('close', function() { |
|
|
|
|
|
clearTimeout(timer); |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
return false; |
|
|
} else { |
|
|
} else { |
|
|
// buffer, as long as we're not destroyed.
|
|
|
// buffer, as long as we're not destroyed.
|
|
|
this._buffer(data, encoding); |
|
|
this._buffer(data, encoding); |
|
|