Skip to content

Commit

Permalink
opt: don't disable SO_REUSEPORT on DragonFlyBSD
Browse files Browse the repository at this point in the history
Fixes #582
  • Loading branch information
panjf2000 committed Apr 21, 2024
1 parent 39f6002 commit a071a94
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion gnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit a071a94

Please sign in to comment.