net: hook up handle wrap to owning object
This commit is contained in:
parent
25aea2a072
commit
f66f793c07
14
lib/net.js
14
lib/net.js
@ -120,7 +120,7 @@ function initSocketHandle(self) {
|
|||||||
|
|
||||||
// Handle creation may be deferred to bind() or connect() time.
|
// Handle creation may be deferred to bind() or connect() time.
|
||||||
if (self._handle) {
|
if (self._handle) {
|
||||||
self._handle.socket = self;
|
self._handle.owner = self;
|
||||||
self._handle.onread = onread;
|
self._handle.onread = onread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -291,7 +291,7 @@ Socket.prototype.end = function(data, encoding) {
|
|||||||
|
|
||||||
|
|
||||||
function afterShutdown(status, handle, req) {
|
function afterShutdown(status, handle, req) {
|
||||||
var self = handle.socket;
|
var self = handle.owner;
|
||||||
|
|
||||||
assert.ok(self._flags & FLAG_SHUTDOWN);
|
assert.ok(self._flags & FLAG_SHUTDOWN);
|
||||||
assert.ok(!self.writable);
|
assert.ok(!self.writable);
|
||||||
@ -380,7 +380,7 @@ Socket.prototype.destroy = function(exception) {
|
|||||||
|
|
||||||
function onread(buffer, offset, length) {
|
function onread(buffer, offset, length) {
|
||||||
var handle = this;
|
var handle = this;
|
||||||
var self = handle.socket;
|
var self = handle.owner;
|
||||||
assert.equal(handle, self._handle);
|
assert.equal(handle, self._handle);
|
||||||
|
|
||||||
timers.active(self);
|
timers.active(self);
|
||||||
@ -583,7 +583,7 @@ Socket.prototype.__defineGetter__('bytesWritten', function() {
|
|||||||
|
|
||||||
|
|
||||||
function afterWrite(status, handle, req) {
|
function afterWrite(status, handle, req) {
|
||||||
var self = handle.socket;
|
var self = handle.owner;
|
||||||
|
|
||||||
// callback may come after call to destroy.
|
// callback may come after call to destroy.
|
||||||
if (self.destroyed) {
|
if (self.destroyed) {
|
||||||
@ -722,7 +722,7 @@ Socket.prototype.connect = function(options, cb) {
|
|||||||
|
|
||||||
|
|
||||||
function afterConnect(status, handle, req, readable, writable) {
|
function afterConnect(status, handle, req, readable, writable) {
|
||||||
var self = handle.socket;
|
var self = handle.owner;
|
||||||
|
|
||||||
// callback may come after call to destroy
|
// callback may come after call to destroy
|
||||||
if (self.destroyed) {
|
if (self.destroyed) {
|
||||||
@ -881,7 +881,7 @@ Server.prototype._listen2 = function(address, port, addressType, backlog) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self._handle.onconnection = onconnection;
|
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
|
// Use a backlog of 512 entries. We pass 511 to the listen() call because
|
||||||
// the kernel does: backlogsize = roundup_pow_of_two(backlogsize + 1);
|
// the kernel does: backlogsize = roundup_pow_of_two(backlogsize + 1);
|
||||||
@ -980,7 +980,7 @@ Server.prototype.address = function() {
|
|||||||
|
|
||||||
function onconnection(clientHandle) {
|
function onconnection(clientHandle) {
|
||||||
var handle = this;
|
var handle = this;
|
||||||
var self = handle.socket;
|
var self = handle.owner;
|
||||||
|
|
||||||
debug('onconnection');
|
debug('onconnection');
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user