Skip to content

Commit

Permalink
chore: update the comments of SO_REUSEPORT on AF_UNIX
Browse files Browse the repository at this point in the history
  • Loading branch information
panjf2000 committed Apr 24, 2024
1 parent c2a7318 commit 31a153f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions gnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,11 @@ func createListeners(addrs []string, opts ...Option) ([]*listener, *Options, err
// 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.
// AF_LOCAL with SO_REUSEPORT enables duplicate address and port bindings without
// load balancing on Linux and *BSD. Therefore, disable it for Unix domain sockets.
//
// Despite the fact that SO_REUSEPORT can be set on a Unix domain socket
// via setsockopt() without reporting an error, SO_REUSEPORT is actually
// not supported for sockets of AF_UNIX. Thus, we avoid setting it on the
// Unix domain sockets.
goos := runtime.GOOS
if (options.Multicore || options.NumEventLoop > 1) && options.ReusePort &&
((goos != "linux" && goos != "dragonfly" && goos != "freebsd") || hasUnix) {
Expand Down

0 comments on commit 31a153f

Please sign in to comment.