From 7061c93286b86b14cab4c96dc1b22610c314f2d3 Mon Sep 17 00:00:00 2001 From: klzgrad Date: Mon, 22 Jul 2024 00:43:37 +0800 Subject: [PATCH] Ignore SO_REUSEPORT not implement error --- src/net/socket/tcp_socket_posix.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/net/socket/tcp_socket_posix.cc b/src/net/socket/tcp_socket_posix.cc index b7758c29b4..730d21b4ec 100644 --- a/src/net/socket/tcp_socket_posix.cc +++ b/src/net/socket/tcp_socket_posix.cc @@ -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(&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(); }