@@ -128,31 +128,29 @@ function RoundRobinHandle(key, address, port, addressType, backlog, fd) {
128
128
else
129
129
this . server . listen ( address ) ; // UNIX socket path.
130
130
131
- var self = this ;
132
- this . server . once ( 'listening' , function ( ) {
133
- self . handle = self . server . _handle ;
134
- self . handle . onconnection = self . distribute . bind ( self ) ;
135
- self . server . _handle = null ;
136
- self . server = null ;
131
+ this . server . once ( 'listening' , ( ) => {
132
+ this . handle = this . server . _handle ;
133
+ this . handle . onconnection = ( err , handle ) => this . distribute ( err , handle ) ;
134
+ this . server . _handle = null ;
135
+ this . server = null ;
137
136
} ) ;
138
137
}
139
138
140
139
RoundRobinHandle . prototype . add = function ( worker , send ) {
141
140
assert ( worker . id in this . all === false ) ;
142
141
this . all [ worker . id ] = worker ;
143
142
144
- var self = this ;
145
- function done ( ) {
146
- if ( self . handle . getsockname ) {
143
+ const done = ( ) => {
144
+ if ( this . handle . getsockname ) {
147
145
var out = { } ;
148
- self . handle . getsockname ( out ) ;
146
+ this . handle . getsockname ( out ) ;
149
147
// TODO(bnoordhuis) Check err.
150
148
send ( null , { sockname : out } , null ) ;
151
149
} else {
152
150
send ( null , null , null ) ; // UNIX socket.
153
151
}
154
- self . handoff ( worker ) ; // In case there are connections pending.
155
- }
152
+ this . handoff ( worker ) ; // In case there are connections pending.
153
+ } ;
156
154
157
155
if ( this . server === null ) return done ( ) ;
158
156
// Still busy binding.
@@ -194,13 +192,13 @@ RoundRobinHandle.prototype.handoff = function(worker) {
194
192
return ;
195
193
}
196
194
var message = { act : 'newconn' , key : this . key } ;
197
- var self = this ;
198
- sendHelper ( worker . process , message , handle , function ( reply ) {
195
+
196
+ sendHelper ( worker . process , message , handle , ( reply ) => {
199
197
if ( reply . accepted )
200
198
handle . close ( ) ;
201
199
else
202
- self . distribute ( 0 , handle ) ; // Worker is shutting down. Send to another.
203
- self . handoff ( worker ) ;
200
+ this . distribute ( 0 , handle ) ; // Worker is shutting down. Send to another.
201
+ this . handoff ( worker ) ;
204
202
} ) ;
205
203
} ;
206
204
@@ -415,7 +413,7 @@ function masterInit() {
415
413
cluster . disconnect = function ( cb ) {
416
414
var workers = Object . keys ( cluster . workers ) ;
417
415
if ( workers . length === 0 ) {
418
- process . nextTick ( intercom . emit . bind ( intercom , 'disconnect' ) ) ;
416
+ process . nextTick ( ( ) => intercom . emit ( 'disconnect' ) ) ;
419
417
} else {
420
418
for ( var key in workers ) {
421
419
key = workers [ key ] ;
@@ -437,7 +435,7 @@ function masterInit() {
437
435
signo = signo || 'SIGTERM' ;
438
436
var proc = this . process ;
439
437
if ( this . isConnected ( ) ) {
440
- this . once ( 'disconnect' , proc . kill . bind ( proc , signo ) ) ;
438
+ this . once ( 'disconnect' , ( ) => proc . kill ( signo ) ) ;
441
439
this . disconnect ( ) ;
442
440
return ;
443
441
}
0 commit comments