From 909e78e18e9335180f83552743fbede0e17492c4 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 10 Dec 2016 14:50:00 -0800 Subject: [PATCH] squash: use setInterval instead of chaining setTimeouts --- .../test-dgram-exclusive-implicit-bind.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/test/parallel/test-dgram-exclusive-implicit-bind.js b/test/parallel/test-dgram-exclusive-implicit-bind.js index e9fbf54e06e673..9bb08b2052f0ce 100644 --- a/test/parallel/test-dgram-exclusive-implicit-bind.js +++ b/test/parallel/test-dgram-exclusive-implicit-bind.js @@ -84,10 +84,10 @@ if (cluster.isMaster) { } const source = dgram.createSocket('udp4'); -var timer; +var interval; source.on('close', function() { - clearTimeout(timer); + clearTimeout(interval); }); if (process.env.BOUND === 'y') { @@ -99,12 +99,7 @@ if (process.env.BOUND === 'y') { source.unref(); } -function send() { - const buf = Buffer.from(process.pid.toString()); - timer = setTimeout(function() { - source.send(buf, common.PORT, '127.0.0.1', send); - }, 1); - timer.unref(); -} - -send(); +const buf = Buffer.from(process.pid.toString()); +interval = setInterval(() => { + source.send(buf, common.PORT, '127.0.0.1'); +}, 1).unref();