From c563569b558e7545a6ca9e3acb658287c78a45b7 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 | 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 26e01f100258f0..3fa7f6472f096c 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.