From be29823ea26033a3d5a4818d5393433e79a11fe7 Mon Sep 17 00:00:00 2001 From: theanarkh Date: Wed, 16 Oct 2024 09:36:16 +0800 Subject: [PATCH] lib: add UV_UDP_REUSEPORT for udp --- doc/api/dgram.md | 16 +++++++-- lib/dgram.js | 7 +++- src/udp_wrap.cc | 1 + test/common/udp.js | 25 +++++++++++++ .../test-child-process-dgram-reuseport.js | 35 +++++++++++++++++++ test/parallel/test-cluster-dgram-reuseport.js | 31 ++++++++++++++++ test/parallel/test-dgram-reuseport.js | 19 ++++++++++ 7 files changed, 131 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 26e01f100258f0..f12ad599acfafd 100644 --- a/doc/api/dgram.md +++ b/doc/api/dgram.md @@ -343,7 +343,8 @@ 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. If creating a `dgram.Socket` with `reusePort` +flag, `exclusive` will always be `true` when call `socket.bind()` with a port. A bound datagram socket keeps the Node.js process running to receive datagram messages. @@ -916,6 +917,9 @@ chained.