@@ -120,6 +120,7 @@ function Socket(options) {
120
120
this . _connecting = false ;
121
121
this . _hadError = false ;
122
122
this . _handle = null ;
123
+ this . _parent = null ;
123
124
this . _host = null ;
124
125
125
126
if ( typeof options === 'number' )
@@ -445,7 +446,8 @@ Socket.prototype._destroy = function(exception, cb) {
445
446
446
447
this . readable = this . writable = false ;
447
448
448
- timers . unenroll ( this ) ;
449
+ for ( var s = this ; s !== null ; s = s . _parent )
450
+ timers . unenroll ( s ) ;
449
451
450
452
debug ( 'close' ) ;
451
453
if ( this . _handle ) {
@@ -490,7 +492,8 @@ function onread(nread, buffer) {
490
492
var self = handle . owner ;
491
493
assert ( handle === self . _handle , 'handle != self._handle' ) ;
492
494
493
- timers . _unrefActive ( self ) ;
495
+ for ( var s = self ; s !== null ; s = s . _parent )
496
+ timers . _unrefActive ( s ) ;
494
497
495
498
debug ( 'onread' , nread ) ;
496
499
@@ -621,7 +624,8 @@ Socket.prototype._writeGeneric = function(writev, data, encoding, cb) {
621
624
this . _pendingData = null ;
622
625
this . _pendingEncoding = '' ;
623
626
624
- timers . _unrefActive ( this ) ;
627
+ for ( var s = this ; s !== null ; s = s . _parent )
628
+ timers . _unrefActive ( s ) ;
625
629
626
630
if ( ! this . _handle ) {
627
631
this . _destroy ( new Error ( 'This socket is closed.' ) , cb ) ;
@@ -749,7 +753,8 @@ function afterWrite(status, handle, req, err) {
749
753
return ;
750
754
}
751
755
752
- timers . _unrefActive ( self ) ;
756
+ for ( var s = self ; s !== null ; s = s . _parent )
757
+ timers . _unrefActive ( s ) ;
753
758
754
759
if ( self !== process . stderr && self !== process . stdout )
755
760
debug ( 'afterWrite call cb' ) ;
@@ -864,7 +869,8 @@ Socket.prototype.connect = function(options, cb) {
864
869
self . once ( 'connect' , cb ) ;
865
870
}
866
871
867
- timers . _unrefActive ( this ) ;
872
+ for ( var s = this ; s !== null ; s = s . _parent )
873
+ timers . _unrefActive ( s ) ;
868
874
869
875
self . _connecting = true ;
870
876
self . writable = true ;
@@ -919,7 +925,8 @@ Socket.prototype.connect = function(options, cb) {
919
925
self . _destroy ( ) ;
920
926
} ) ;
921
927
} else {
922
- timers . _unrefActive ( self ) ;
928
+ for ( var s = self ; s !== null ; s = s . _parent )
929
+ timers . _unrefActive ( s ) ;
923
930
connect ( self ,
924
931
ip ,
925
932
port ,
@@ -964,7 +971,8 @@ function afterConnect(status, handle, req, readable, writable) {
964
971
if ( status == 0 ) {
965
972
self . readable = readable ;
966
973
self . writable = writable ;
967
- timers . _unrefActive ( self ) ;
974
+ for ( var s = self ; s !== null ; s = s . _parent )
975
+ timers . _unrefActive ( s ) ;
968
976
969
977
self . emit ( 'connect' ) ;
970
978
0 commit comments