From a071a949d3b745d79d9be32029b829c1d1356fef Mon Sep 17 00:00:00 2001 From: Andy Pan Date: Sun, 21 Apr 2024 18:18:34 +0800 Subject: [PATCH] opt: don't disable SO_REUSEPORT on DragonFlyBSD Fixes #582 --- gnet.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gnet.go b/gnet.go index c1b809649..80fe4c916 100644 --- a/gnet.go +++ b/gnet.go @@ -476,8 +476,11 @@ func createListeners(addrs []string, opts ...Option) ([]*listener, *Options, err // // Note that FreeBSD 12 introduced a new socket option named SO_REUSEPORT_LB // with the capability of load balancing, it's the equivalent of Linux's SO_REUSEPORT. + // Also note that DragonFlyBSD 3.6.0 extended SO_REUSEPORT to distribute workload to + // available sockets, which make it the same as Linux's SO_REUSEPORT. goos := runtime.GOOS - if (options.Multicore || options.NumEventLoop > 1) && options.ReusePort && goos != "linux" && goos != "freebsd" { + if (options.Multicore || options.NumEventLoop > 1) && options.ReusePort && + goos != "linux" && goos != "dragonfly" && goos != "freebsd" { options.ReusePort = false }