Skip to content

Commit 0e982e4

Browse files
panjf2000andyl
authored and
andyl
committed
opt: don't disable SO_REUSEPORT on DragonFlyBSD (panjf2000#583)
Fixes panjf2000#582
1 parent 7717171 commit 0e982e4

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

gnet.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -474,15 +474,18 @@ func createListeners(addrs []string, opts ...Option) ([]*listener, *Options, err
474474
// Linux implemented SO_REUSEPORT with load balancing for incoming connections
475475
// while *BSD implemented it for only binding to the same address and port, which
476476
// makes it pointless to enable SO_REUSEPORT on *BSD and Darwin for gnet with
477-
// multiple event-loops because only the first event-loop will be constantly woken
478-
// up to accept incoming connections and handle I/O events while the rest of event
479-
// loops remain idle.
477+
// multiple event-loops because only the first or last event-loop will be constantly
478+
// woken up to accept incoming connections and handle I/O events while the rest of
479+
// event-loops remain idle.
480480
// Thus, we disable SO_REUSEPORT on *BSD and Darwin by default.
481481
//
482482
// Note that FreeBSD 12 introduced a new socket option named SO_REUSEPORT_LB
483483
// with the capability of load balancing, it's the equivalent of Linux's SO_REUSEPORT.
484+
// Also note that DragonFlyBSD 3.6.0 extended SO_REUSEPORT to distribute workload to
485+
// available sockets, which make it the same as Linux's SO_REUSEPORT.
484486
goos := runtime.GOOS
485-
if (options.Multicore || options.NumEventLoop > 1) && options.ReusePort && goos != "linux" && goos != "freebsd" {
487+
if (options.Multicore || options.NumEventLoop > 1) && options.ReusePort &&
488+
goos != "linux" && goos != "dragonfly" && goos != "freebsd" {
486489
options.ReusePort = false
487490
}
488491

0 commit comments

Comments
 (0)