@@ -83,8 +83,14 @@ if (process.argv[2] !== 'child') {
8383 let i = 0;
8484 let done = 0;
8585 let 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(() => {
8894 console.error('[PARENT] Responses were not received within %d ms.',
8995 TIMEOUT);
9096 console.error('[PARENT] Skip');
@@ -115,7 +121,7 @@ if (process.argv[2] !== 'child') {
115121 worker.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.
121127 if (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) => {
142148 if (msg.listening) {
143149 listening += 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) => {
166172 const worker = workers[pid];
167173
168174 let count = 0;
169175
170- worker.messagesReceived.forEach(function (buf) {
176+ worker.messagesReceived.forEach((buf) => {
171177 for (let i = 0; i < worker.messagesNeeded.length; ++i) {
172178 if (buf.toString() === worker.messagesNeeded[i]) {
173179 count++;
@@ -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.
203209 sendSocket.bind(common.PORT, ANY[FAM]);
204- sendSocket.on('listening', function() {
210+ sendSocket.on('listening', () => {
205211 console.error(`outgoing iface ${interfaceAddress}`);
206212 });
207213
208- sendSocket.on('close', function() {
214+ sendSocket.on('close', () => {
209215 console.error('[PARENT] sendSocket closed');
210216 });
211217
212- sendSocket.sendNext = function() {
218+ sendSocket.sendNext = () => {
213219 const msg = messages[i++];
214220
215221 if (!msg) {
@@ -228,7 +234,7 @@ if (process.argv[2] !== 'child') {
228234 buf.length,
229235 PORTS[msg.mcast],
230236 msg.mcast,
231- function (err) {
237+ (err) => {
232238 assert.ifError(err);
233239 console.error('[PARENT] sent %s to %s:%s',
234240 util.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') {
258259 reuseAddr: 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.
263264 if (!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', () => {
284285 listenSocket.addMembership(MULTICAST, IFACE);
285286 process.send({ listening: true });
286287 });
0 commit comments