@@ -56,7 +56,7 @@ const {
56
56
const {
57
57
newAsyncId,
58
58
defaultTriggerAsyncIdScope,
59
- symbols : { async_id_symbol }
59
+ symbols : { async_id_symbol, owner_symbol }
60
60
} = require ( 'internal/async_hooks' ) ;
61
61
const {
62
62
createWriteWrap,
@@ -207,7 +207,7 @@ function initSocketHandle(self) {
207
207
208
208
// Handle creation may be deferred to bind() or connect() time.
209
209
if ( self . _handle ) {
210
- self . _handle . owner = self ;
210
+ self . _handle [ owner_symbol ] = self ;
211
211
self . _handle . onread = onread ;
212
212
self [ async_id_symbol ] = getNewAsyncId ( self . _handle ) ;
213
213
}
@@ -371,7 +371,7 @@ Socket.prototype._final = function(cb) {
371
371
372
372
373
373
function afterShutdown ( status , handle ) {
374
- var self = handle . owner ;
374
+ var self = handle [ owner_symbol ] ;
375
375
376
376
debug ( 'afterShutdown destroyed=%j' , self . destroyed ,
377
377
self . _readableState ) ;
@@ -620,7 +620,7 @@ Socket.prototype._destroy = function(exception, cb) {
620
620
// buffer, or when there's an error reading.
621
621
function onread ( nread , buffer ) {
622
622
var handle = this ;
623
- var self = handle . owner ;
623
+ var self = handle [ owner_symbol ] ;
624
624
assert ( handle === self . _handle , 'handle != self._handle' ) ;
625
625
626
626
self . _unrefTimer ( ) ;
@@ -819,7 +819,7 @@ protoGetter('bytesWritten', function bytesWritten() {
819
819
820
820
821
821
function afterWrite ( status , handle , err ) {
822
- var self = handle . owner ;
822
+ var self = handle [ owner_symbol ] ;
823
823
if ( self !== process . stderr && self !== process . stdout )
824
824
debug ( 'afterWrite' , status ) ;
825
825
@@ -1121,7 +1121,7 @@ Socket.prototype.unref = function() {
1121
1121
1122
1122
1123
1123
function afterConnect ( status , handle , req , readable , writable ) {
1124
- var self = handle . owner ;
1124
+ var self = handle [ owner_symbol ] ;
1125
1125
1126
1126
// callback may come after call to destroy
1127
1127
if ( self . destroyed ) {
@@ -1323,7 +1323,7 @@ function setupListenHandle(address, port, addressType, backlog, fd) {
1323
1323
1324
1324
this [ async_id_symbol ] = getNewAsyncId ( this . _handle ) ;
1325
1325
this . _handle . onconnection = onconnection ;
1326
- this . _handle . owner = this ;
1326
+ this . _handle [ owner_symbol ] = this ;
1327
1327
1328
1328
// Use a backlog of 512 entries. We pass 511 to the listen() call because
1329
1329
// the kernel does: backlogsize = roundup_pow_of_two(backlogsize + 1);
@@ -1536,7 +1536,7 @@ Server.prototype.address = function() {
1536
1536
1537
1537
function onconnection ( err , clientHandle ) {
1538
1538
var handle = this ;
1539
- var self = handle . owner ;
1539
+ var self = handle [ owner_symbol ] ;
1540
1540
1541
1541
debug ( 'onconnection' ) ;
1542
1542
@@ -1667,6 +1667,14 @@ function emitCloseNT(self) {
1667
1667
}
1668
1668
1669
1669
1670
+ // Legacy alias on the C++ wrapper object. This is not public API, so we may
1671
+ // want to runtime-deprecate it at some point. There's no hurry, though.
1672
+ Object . defineProperty ( TCP . prototype , 'owner' , {
1673
+ get ( ) { return this [ owner_symbol ] ; } ,
1674
+ set ( v ) { return this [ owner_symbol ] = v ; }
1675
+ } ) ;
1676
+
1677
+
1670
1678
Server . prototype . listenFD = internalUtil . deprecate ( function ( fd , type ) {
1671
1679
return this . listen ( { fd : fd } ) ;
1672
1680
} , 'Server.listenFD is deprecated. Use Server.listen({fd: <number>}) instead.' ,
0 commit comments