handle-thing
Advanced tools
Comparing version 1.2.3 to 1.2.4
@@ -19,2 +19,3 @@ var assert = require('assert'); | ||
this._flowing = false; | ||
this._reading = false; | ||
this._options = options || {}; | ||
@@ -47,2 +48,9 @@ | ||
this.writeQueueSize = 1; | ||
if (mode === 'rusty') { | ||
if (this._stream) | ||
this._rustyInit(); | ||
else | ||
this.once('stream', this._rustyInit); | ||
} | ||
} | ||
@@ -52,2 +60,4 @@ util.inherits(Handle, EventEmitter); | ||
Handle.mode = mode; | ||
Handle.create = function create(stream, options) { | ||
@@ -76,2 +86,4 @@ return new Handle(stream, options); | ||
Handle.prototype.readStart = function readStart() { | ||
this._reading = true; | ||
if (!this._stream) { | ||
@@ -92,2 +104,4 @@ this.once('stream', this.readStart); | ||
Handle.prototype.readStop = function readStop() { | ||
this._reading = false; | ||
if (!this._stream) { | ||
@@ -113,2 +127,9 @@ this.once('stream', this.readStop); | ||
}); | ||
this._stream.on('close', function() { | ||
setImmediate(function() { | ||
if (self._reading) | ||
self.onread(uv.UV_ECONNRESET, new Buffer(0)); | ||
}); | ||
}); | ||
}; | ||
@@ -143,2 +164,15 @@ | ||
}); | ||
this._stream.on('close', function() { | ||
setImmediate(function() { | ||
if (!self._reading) | ||
return; | ||
var errno = process._errno; | ||
process._errno = 'ECONNRESET'; | ||
self.onread(null, 0, 0); | ||
if (process._errno === 'ECONNRESET') | ||
process._errno = errno; | ||
}); | ||
}); | ||
}; | ||
@@ -161,2 +195,19 @@ | ||
} else { | ||
Handle.prototype._rustyInit = function _rustyInit() { | ||
var self = this; | ||
this._stream.on('close', function() { | ||
process.nextTick(function() { | ||
if (!self._reading) | ||
return; | ||
var errno = global.errno; | ||
global.errno = 'ECONNRESET'; | ||
self.onread(null, 0, 0); | ||
if (global.errno === 'ECONNRESET') | ||
global.errno = errno; | ||
}); | ||
}); | ||
}; | ||
Handle.prototype._flow = function flow() { | ||
@@ -163,0 +214,0 @@ var self = this; |
{ | ||
"name": "handle-thing", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"description": "Wrap Streams2 instance into a HandleWrap", | ||
@@ -5,0 +5,0 @@ "main": "lib/handle.js", |
@@ -96,2 +96,19 @@ var assert = require('assert'); | ||
}); | ||
it('should emit ECONNRESET at `close` event', function(done) { | ||
pair.other.emit('close'); | ||
// No error emitted in v0.8 | ||
if (thing.mode === 'rusty') { | ||
socket.on('close', function() { | ||
done(); | ||
}); | ||
return; | ||
} | ||
socket.on('error', function(err) { | ||
assert(/ECONNRESET/.test(err.message)); | ||
done(); | ||
}); | ||
}); | ||
} | ||
@@ -98,0 +115,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15576
485