From aedc7120ea4b946b655a6de64297be1f40ad583a Mon Sep 17 00:00:00 2001 From: sylkat Date: Mon, 3 Sep 2018 01:40:28 +0800 Subject: [PATCH 1/8] src: fix bootstrap_node on bsd Currently makes a call to `realpathSync.native` which doesn't exist on 8.x or lower PR-URL: https://github.com/nodejs/node/pull/22663 Reviewed-By: Anna Henningsen Reviewed-By: Myles Borins --- lib/internal/bootstrap_node.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/bootstrap_node.js b/lib/internal/bootstrap_node.js index 3cadf1e399e51b..f09e9a5beb023d 100644 --- a/lib/internal/bootstrap_node.js +++ b/lib/internal/bootstrap_node.js @@ -70,7 +70,7 @@ // get the full path before process.execPath is used. if (process.platform === 'openbsd') { const { realpathSync } = NativeModule.require('fs'); - process.execPath = realpathSync.native(process.execPath); + process.execPath = realpathSync(process.execPath); } Object.defineProperty(process, 'argv0', { From ad62971573902ac5c379d7a4b6ccf423ed5eaf3b Mon Sep 17 00:00:00 2001 From: James M Snell Date: Thu, 18 Oct 2018 18:12:59 -0700 Subject: [PATCH 2/8] doc: document that addMembership must be called once in a cluster Fixes: https://github.com/nodejs/node/issues/12572 Refs: https://github.com/nodejs/node/pull/16240 PR-URL: https://github.com/nodejs/node/pull/23746 Reviewed-By: Refael Ackermann Reviewed-By: Luigi Pinca Reviewed-By: Trivikram Kamat --- doc/api/dgram.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/doc/api/dgram.md b/doc/api/dgram.md index 93a1d186e7c620..6553c4a0323ced 100644 --- a/doc/api/dgram.md +++ b/doc/api/dgram.md @@ -95,6 +95,24 @@ Tells the kernel to join a multicast group at the given `multicastAddress` and one interface and will add membership to it. To add membership to every available interface, call `addMembership` multiple times, once per interface. +When sharing a UDP socket across multiple `cluster` workers, the +`socket.addMembership()` function must be called only once or an +`EADDRINUSE` error will occur: + +```js +const cluster = require('cluster'); +const dgram = require('dgram'); +if (cluster.isMaster) { + cluster.fork(); // Works ok. + cluster.fork(); // Fails with EADDRINUSE. +} else { + const s = dgram.createSocket('udp4'); + s.bind(1234, () => { + s.addMembership('224.0.0.114'); + }); +} +``` + ### socket.address()