From 6a02c2701e34eebcbbbeced061507af7d6481820 Mon Sep 17 00:00:00 2001 From: theanarkh Date: Mon, 21 Oct 2024 18:25:10 +0800 Subject: [PATCH] lib: add UV_UDP_REUSEPORT for udp PR-URL: https://github.com/nodejs/node/pull/55403 Refs: https://github.com/libuv/libuv/pull/4419 Reviewed-By: Matteo Collina Reviewed-By: James M Snell --- doc/api/dgram.md | 17 +++++++- lib/dgram.js | 7 +++- src/udp_wrap.cc | 1 + test/common/udp.js | 24 ++++++++++++ .../test-child-process-dgram-reuseport.js | 35 +++++++++++++++++ test/parallel/test-cluster-dgram-reuseport.js | 39 +++++++++++++++++++ test/parallel/test-dgram-reuseport.js | 21 ++++++++++ 7 files changed, 141 insertions(+), 3 deletions(-) create mode 100644 test/common/udp.js create mode 100644 test/parallel/test-child-process-dgram-reuseport.js create mode 100644 test/parallel/test-cluster-dgram-reuseport.js create mode 100644 test/parallel/test-dgram-reuseport.js diff --git a/doc/api/dgram.md b/doc/api/dgram.md index 26e01f10025..3fa7f6472f0 100644 --- a/doc/api/dgram.md +++ b/doc/api/dgram.md @@ -343,7 +343,9 @@ used when using `dgram.Socket` objects with the [`cluster`][] module. When `exclusive` is set to `false` (the default), cluster workers will use the same underlying socket handle allowing connection handling duties to be shared. When `exclusive` is `true`, however, the handle is not shared and attempted -port sharing results in an error. +port sharing results in an error. Creating a `dgram.Socket` with the `reusePort` +option set to `true` causes `exclusive` to always be `true` when `socket.bind()` +is called. A bound datagram socket keeps the Node.js process running to receive datagram messages. @@ -916,6 +918,9 @@ chained.