@@ -83,8 +83,14 @@ if (process.argv[2] !== 'child') {
83
83
let i = 0 ;
84
84
let done = 0 ;
85
85
let timer = null ;
86
+
87
+ const killSubprocesses = ( subprocesses ) => {
88
+ for ( const i in subprocesses )
89
+ subprocesses [ i ] . kill ( ) ;
90
+ } ;
91
+
86
92
// Exit the test if it doesn't succeed within the TIMEOUT.
87
- timer = setTimeout ( function ( ) {
93
+ timer = setTimeout ( ( ) => {
88
94
console . error ( '[PARENT] Responses were not received within %d ms.' ,
89
95
TIMEOUT ) ;
90
96
console . error ( '[PARENT] Skip' ) ;
@@ -115,7 +121,7 @@ if (process.argv[2] !== 'child') {
115
121
worker . messagesNeeded = messagesNeeded ;
116
122
117
123
// Handle the death of workers.
118
- worker . on ( 'exit' , function ( code , signal ) {
124
+ worker . on ( 'exit' , ( code ) => {
119
125
// Don't consider this a true death if the worker has finished
120
126
// successfully or if the exit code is 0.
121
127
if ( worker . isDone || code === 0 ) {
@@ -138,7 +144,7 @@ if (process.argv[2] !== 'child') {
138
144
}
139
145
} ) ;
140
146
141
- worker . on ( 'message' , function ( msg ) {
147
+ worker . on ( 'message' , ( msg ) => {
142
148
if ( msg . listening ) {
143
149
listening += 1 ;
144
150
@@ -162,12 +168,12 @@ if (process.argv[2] !== 'child') {
162
168
'required number of ' +
163
169
'messages. Will now compare.' ) ;
164
170
165
- Object . keys ( workers ) . forEach ( function ( pid ) {
171
+ Object . keys ( workers ) . forEach ( ( pid ) => {
166
172
const worker = workers [ pid ] ;
167
173
168
174
let count = 0 ;
169
175
170
- worker . messagesReceived . forEach ( function ( buf ) {
176
+ worker . messagesReceived . forEach ( ( buf ) => {
171
177
for ( let i = 0 ; i < worker . messagesNeeded . length ; ++ i ) {
172
178
if ( buf . toString ( ) === worker . messagesNeeded [ i ] ) {
173
179
count ++ ;
@@ -201,15 +207,15 @@ if (process.argv[2] !== 'child') {
201
207
// Don't bind the address explicitly when sending and start with
202
208
// the OSes default multicast interface selection.
203
209
sendSocket . bind ( common . PORT , ANY [ FAM ] ) ;
204
- sendSocket . on ( 'listening' , function ( ) {
210
+ sendSocket . on ( 'listening' , ( ) => {
205
211
console . error ( `outgoing iface ${ interfaceAddress } ` ) ;
206
212
} ) ;
207
213
208
- sendSocket . on ( 'close' , function ( ) {
214
+ sendSocket . on ( 'close' , ( ) => {
209
215
console . error ( '[PARENT] sendSocket closed' ) ;
210
216
} ) ;
211
217
212
- sendSocket . sendNext = function ( ) {
218
+ sendSocket . sendNext = ( ) => {
213
219
const msg = messages [ i ++ ] ;
214
220
215
221
if ( ! msg ) {
@@ -228,7 +234,7 @@ if (process.argv[2] !== 'child') {
228
234
buf . length ,
229
235
PORTS [ msg . mcast ] ,
230
236
msg . mcast ,
231
- function ( err ) {
237
+ ( err ) => {
232
238
assert . ifError ( err ) ;
233
239
console . error ( '[PARENT] sent %s to %s:%s' ,
234
240
util . inspect ( buf . toString ( ) ) ,
@@ -238,11 +244,6 @@ if (process.argv[2] !== 'child') {
238
244
}
239
245
) ;
240
246
} ;
241
-
242
- function killSubprocesses ( subprocesses ) {
243
- for ( const i in subprocesses )
244
- subprocesses [ i ] . kill ( ) ;
245
- }
246
247
}
247
248
248
249
if ( process . argv [ 2 ] === 'child' ) {
@@ -258,7 +259,7 @@ if (process.argv[2] === 'child') {
258
259
reuseAddr : true
259
260
} ) ;
260
261
261
- listenSocket . on ( 'message' , function ( buf , rinfo ) {
262
+ listenSocket . on ( 'message' , ( buf , rinfo ) => {
262
263
// Examine udp messages only when they were sent by the parent.
263
264
if ( ! buf . toString ( ) . startsWith ( SESSION ) ) return ;
264
265
@@ -280,7 +281,7 @@ if (process.argv[2] === 'child') {
280
281
} ) ;
281
282
282
283
283
- listenSocket . on ( 'listening' , function ( ) {
284
+ listenSocket . on ( 'listening' , ( ) => {
284
285
listenSocket . addMembership ( MULTICAST , IFACE ) ;
285
286
process . send ( { listening : true } ) ;
286
287
} ) ;
0 commit comments