Ignore SO_REUSEPORT not implement error

This commit is contained in:
klzgrad 2024-07-22 00:43:37 +08:00
parent 3df753204d
commit 7061c93286

View File

@ -388,15 +388,15 @@ int TCPSocketPosix::GetPeerAddress(IPEndPoint* address) const {
int TCPSocketPosix::SetDefaultOptionsForServer() {
DCHECK(socket_);
#if BUILDFLAG(IS_LINUX)
#ifdef SO_REUSEPORT
int reuseport = 1;
int rv =
setsockopt(socket_->socket_fd(), SOL_SOCKET, SO_REUSEPORT,
reinterpret_cast<const char*>(&reuseport), sizeof(reuseport));
if (rv < 0) {
// Ignore errors that the option does not exist.
if (rv != 0 && errno != ENOPROTOOPT)
return MapSystemError(errno);
}
#endif
#endif // SO_REUSEPORT
return AllowAddressReuse();
}