Skip to content

Commit

Permalink
net: Use SO_REUSEPORT for server sockets
Browse files Browse the repository at this point in the history
  • Loading branch information
klzgrad committed Mar 10, 2024
1 parent 0a958de commit 8a3cb33
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/net/socket/tcp_socket_posix.cc
Expand Up @@ -387,6 +387,17 @@ int TCPSocketPosix::GetPeerAddress(IPEndPoint* address) const {

int TCPSocketPosix::SetDefaultOptionsForServer() {
DCHECK(socket_);

#if BUILDFLAG(IS_LINUX)
int reuseport = 1;
int rv =
setsockopt(socket_->socket_fd(), SOL_SOCKET, SO_REUSEPORT,
reinterpret_cast<const char*>(&reuseport), sizeof(reuseport));
if (rv < 0) {
return MapSystemError(errno);
}
#endif

return AllowAddressReuse();
}

Expand Down

0 comments on commit 8a3cb33

Please sign in to comment.