@@ -127,31 +127,29 @@ function RoundRobinHandle(key, address, port, addressType, backlog, fd) {
127127 else
128128 this . server . listen ( address ) ; // UNIX socket path.
129129
130- var self = this ;
131- this . server . once ( 'listening' , function ( ) {
132- self . handle = self . server . _handle ;
133- self . handle . onconnection = self . distribute . bind ( self ) ;
134- self . server . _handle = null ;
135- self . server = null ;
130+ this . server . once ( 'listening' , ( ) => {
131+ this . handle = this . server . _handle ;
132+ this . handle . onconnection = ( err , handle ) => this . distribute ( err , handle ) ;
133+ this . server . _handle = null ;
134+ this . server = null ;
136135 } ) ;
137136}
138137
139138RoundRobinHandle . prototype . add = function ( worker , send ) {
140139 assert ( worker . id in this . all === false ) ;
141140 this . all [ worker . id ] = worker ;
142141
143- var self = this ;
144- function done ( ) {
145- if ( self . handle . getsockname ) {
142+ const done = ( ) => {
143+ if ( this . handle . getsockname ) {
146144 var out = { } ;
147- self . handle . getsockname ( out ) ;
145+ this . handle . getsockname ( out ) ;
148146 // TODO(bnoordhuis) Check err.
149147 send ( null , { sockname : out } , null ) ;
150148 } else {
151149 send ( null , null , null ) ; // UNIX socket.
152150 }
153- self . handoff ( worker ) ; // In case there are connections pending.
154- }
151+ this . handoff ( worker ) ; // In case there are connections pending.
152+ } ;
155153
156154 if ( this . server === null ) return done ( ) ;
157155 // Still busy binding.
@@ -193,13 +191,13 @@ RoundRobinHandle.prototype.handoff = function(worker) {
193191 return ;
194192 }
195193 var message = { act : 'newconn' , key : this . key } ;
196- var self = this ;
197- sendHelper ( worker . process , message , handle , function ( reply ) {
194+
195+ sendHelper ( worker . process , message , handle , ( reply ) => {
198196 if ( reply . accepted )
199197 handle . close ( ) ;
200198 else
201- self . distribute ( 0 , handle ) ; // Worker is shutting down. Send to another.
202- self . handoff ( worker ) ;
199+ this . distribute ( 0 , handle ) ; // Worker is shutting down. Send to another.
200+ this . handoff ( worker ) ;
203201 } ) ;
204202} ;
205203
@@ -414,7 +412,7 @@ function masterInit() {
414412 cluster . disconnect = function ( cb ) {
415413 var workers = Object . keys ( cluster . workers ) ;
416414 if ( workers . length === 0 ) {
417- process . nextTick ( intercom . emit . bind ( intercom , 'disconnect' ) ) ;
415+ process . nextTick ( ( ) => intercom . emit ( 'disconnect' ) ) ;
418416 } else {
419417 for ( var key in workers ) {
420418 key = workers [ key ] ;
@@ -436,7 +434,7 @@ function masterInit() {
436434 signo = signo || 'SIGTERM' ;
437435 var proc = this . process ;
438436 if ( this . isConnected ( ) ) {
439- this . once ( 'disconnect' , proc . kill . bind ( proc , signo ) ) ;
437+ this . once ( 'disconnect' , ( ) => proc . kill ( signo ) ) ;
440438 this . disconnect ( ) ;
441439 return ;
442440 }
0 commit comments