net: hook up handle wrap to owning object

This commit is contained in:
Ben Noordhuis 2012-04-27 04:42:10 +02:00
parent 25aea2a072
commit f66f793c07

View File

@ -120,7 +120,7 @@ function initSocketHandle(self) {
// Handle creation may be deferred to bind() or connect() time.
if (self._handle) {
self._handle.socket = self;
self._handle.owner = self;
self._handle.onread = onread;
}
}
@ -291,7 +291,7 @@ Socket.prototype.end = function(data, encoding) {
function afterShutdown(status, handle, req) {
var self = handle.socket;
var self = handle.owner;
assert.ok(self._flags & FLAG_SHUTDOWN);
assert.ok(!self.writable);
@ -380,7 +380,7 @@ Socket.prototype.destroy = function(exception) {
function onread(buffer, offset, length) {
var handle = this;
var self = handle.socket;
var self = handle.owner;
assert.equal(handle, self._handle);
timers.active(self);
@ -583,7 +583,7 @@ Socket.prototype.__defineGetter__('bytesWritten', function() {
function afterWrite(status, handle, req) {
var self = handle.socket;
var self = handle.owner;
// callback may come after call to destroy.
if (self.destroyed) {
@ -722,7 +722,7 @@ Socket.prototype.connect = function(options, cb) {
function afterConnect(status, handle, req, readable, writable) {
var self = handle.socket;
var self = handle.owner;
// callback may come after call to destroy
if (self.destroyed) {
@ -881,7 +881,7 @@ Server.prototype._listen2 = function(address, port, addressType, backlog) {
}
self._handle.onconnection = onconnection;
self._handle.socket = self;
self._handle.owner = self;
// Use a backlog of 512 entries. We pass 511 to the listen() call because
// the kernel does: backlogsize = roundup_pow_of_two(backlogsize + 1);
@ -980,7 +980,7 @@ Server.prototype.address = function() {
function onconnection(clientHandle) {
var handle = this;
var self = handle.socket;
var self = handle.owner;
debug('onconnection');