@@ -83,8 +83,14 @@ if (process.argv[2] !== 'child') {
8383let i = 0 ;
8484let done = 0 ;
8585let timer = null ;
86+
87+ const killSubprocesses = ( subprocesses ) => {
88+ for ( const i in subprocesses )
89+ subprocesses [ i ] . kill ( ) ;
90+ } ;
91+
8692// Exit the test if it doesn't succeed within the TIMEOUT.
87- timer = setTimeout ( function ( ) {
93+ timer = setTimeout ( ( ) => {
8894console . error ( '[PARENT] Responses were not received within %d ms.' ,
8995TIMEOUT ) ;
9096console . error ( '[PARENT] Skip' ) ;
@@ -115,7 +121,7 @@ if (process.argv[2] !== 'child') {
115121worker . messagesNeeded = messagesNeeded ;
116122
117123// Handle the death of workers.
118- worker . on ( 'exit' , function ( code , signal ) {
124+ worker . on ( 'exit' , ( code ) => {
119125// Don't consider this a true death if the worker has finished
120126// successfully or if the exit code is 0.
121127if ( worker . isDone || code === 0 ) {
@@ -138,7 +144,7 @@ if (process.argv[2] !== 'child') {
138144}
139145} ) ;
140146
141- worker . on ( 'message' , function ( msg ) {
147+ worker . on ( 'message' , ( msg ) => {
142148if ( msg . listening ) {
143149listening += 1 ;
144150
@@ -162,12 +168,12 @@ if (process.argv[2] !== 'child') {
162168'required number of ' +
163169'messages. Will now compare.' ) ;
164170
165- Object . keys ( workers ) . forEach ( function ( pid ) {
171+ Object . keys ( workers ) . forEach ( ( pid ) => {
166172const worker = workers [ pid ] ;
167173
168174let count = 0 ;
169175
170- worker . messagesReceived . forEach ( function ( buf ) {
176+ worker . messagesReceived . forEach ( ( buf ) => {
171177for ( let i = 0 ; i < worker . messagesNeeded . length ; ++ i ) {
172178if ( buf . toString ( ) === worker . messagesNeeded [ i ] ) {
173179count ++ ;
@@ -201,15 +207,15 @@ if (process.argv[2] !== 'child') {
201207// Don't bind the address explicitly when sending and start with
202208// the OSes default multicast interface selection.
203209sendSocket . bind ( common . PORT , ANY [ FAM ] ) ;
204- sendSocket . on ( 'listening' , function ( ) {
210+ sendSocket . on ( 'listening' , ( ) => {
205211console . error ( `outgoing iface ${ interfaceAddress } ` ) ;
206212} ) ;
207213
208- sendSocket . on ( 'close' , function ( ) {
214+ sendSocket . on ( 'close' , ( ) => {
209215console . error ( '[PARENT] sendSocket closed' ) ;
210216} ) ;
211217
212- sendSocket . sendNext = function ( ) {
218+ sendSocket . sendNext = ( ) => {
213219const msg = messages [ i ++ ] ;
214220
215221if ( ! msg ) {
@@ -228,7 +234,7 @@ if (process.argv[2] !== 'child') {
228234buf . length ,
229235PORTS [ msg . mcast ] ,
230236msg . mcast ,
231- function ( err ) {
237+ ( err ) => {
232238assert . ifError ( err ) ;
233239console . error ( '[PARENT] sent %s to %s:%s' ,
234240util . inspect ( buf . toString ( ) ) ,
@@ -238,11 +244,6 @@ if (process.argv[2] !== 'child') {
238244}
239245) ;
240246} ;
241-
242- function killSubprocesses ( subprocesses ) {
243- for ( const i in subprocesses )
244- subprocesses [ i ] . kill ( ) ;
245- }
246247}
247248
248249if ( process . argv [ 2 ] === 'child' ) {
@@ -258,7 +259,7 @@ if (process.argv[2] === 'child') {
258259reuseAddr : true
259260} ) ;
260261
261- listenSocket . on ( 'message' , function ( buf , rinfo ) {
262+ listenSocket . on ( 'message' , ( buf , rinfo ) => {
262263// Examine udp messages only when they were sent by the parent.
263264if ( ! buf . toString ( ) . startsWith ( SESSION ) ) return ;
264265
@@ -280,7 +281,7 @@ if (process.argv[2] === 'child') {
280281} ) ;
281282
282283
283- listenSocket . on ( 'listening' , function ( ) {
284+ listenSocket . on ( 'listening' , ( ) => {
284285listenSocket . addMembership ( MULTICAST , IFACE ) ;
285286process . send ( { listening : true } ) ;
286287} ) ;
0 commit comments