mirror of
https://github.com/klzgrad/naiveproxy.git
synced 2025-04-13 14:11:04 +00:00
net/socket: Use SO_REUSEPORT for server sockets
This commit is contained in:
parent
b228801c5f
commit
343114c3a1
1 changed files with 11 additions and 0 deletions
|
@ -387,6 +387,17 @@ int TCPSocketPosix::GetPeerAddress(IPEndPoint* address) const {
|
||||||
|
|
||||||
int TCPSocketPosix::SetDefaultOptionsForServer() {
|
int TCPSocketPosix::SetDefaultOptionsForServer() {
|
||||||
DCHECK(socket_);
|
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();
|
return AllowAddressReuse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue