panjf2000 / gnet

🚀 gnet is a high-performance, lightweight, non-blocking, event-driven networking framework written in pure Go.

Home Page:https://gnet.host

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Don't use SO_REUSEPORT on Unix domain sockets

panjf2000 opened this issue · comments

SO_REUSEPORT on AF_LOCAL enables duplicate address and port bindings without load balancing on Linux and *BSD.

There is a problem when UDP sockets and Unix domain sockets are together requested to be listened by the gnet server, a conflict arises because we must use SO_REUSEPORT on UDP sockets based on the current architecture of gnet. We can disallow users to listen on both UDP sockets and Unix domain sockets, but it seems unworthy of doing so because even though setting SO_REUSEPORT on both UDP sockets and Unix domain sockets will tip the scales of event-loops, it can work. Therefore, I decided to allow UDP sockets and Unix domain sockets to co-exist and only disable SO_REUSEPORT for Unix domain sockets when there is no UDP sockets.