Skip to content
8 changes: 6 additions & 2 deletions test/parallel/test-cluster-dgram-reuse.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,9 @@ function close() {
cluster.worker.disconnect();
}

for (let i = 0; i < 2; i++)
dgram.createSocket({ type: 'udp4', reuseAddr: true }).bind(common.PORT, next);
const socket = dgram.createSocket({type: 'udp4', reuseAddr: true})
.bind(0, common.mustCall(() => {
const socket2 = socket();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

socket() looks incorrect to me. Should this be dgram.createSocket()?

Copy link
Author

@akopcz2 akopcz2 May 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was under the impression that calling socket() was the same as dgram.createSocket since I declared socket as a const. I updated the code here 41292b7

socket.bind(this.address().port, next);
Copy link
Member

@Trott Trott May 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This runs bind twice on the socket but the existing test runs createSocket() twice and this runs it only once. But running it twice is what is actually being tested here, I think. So this invalidates the test, I think.

Copy link
Author

@akopcz2 akopcz2 May 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Trott Thanks! That makes sense. Would calling another socket inside the callback here work e4f250a ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not so happy about this rebind, you could just do next.call(this).

socket2.bind(this.address().port, next);
}));