Skip to content

Commit

Permalink
squash: use setInterval instead of chaining setTimeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
Trott committed Dec 10, 2016
1 parent 151d2ac commit 909e78e
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions test/parallel/test-dgram-exclusive-implicit-bind.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -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();

0 comments on commit 909e78e

Please sign in to comment.