mirror of
https://github.com/klzgrad/naiveproxy.git
synced 2024-11-24 06:16:30 +03:00
net/socket: Use SO_REUSEPORT for server sockets
This commit is contained in:
parent
4b5ee1d3e1
commit
cfb241dcb7
@ -404,6 +404,17 @@ int TCPSocketPosix::GetPeerAddress(IPEndPoint* address) const {
|
|||||||
|
|
||||||
int TCPSocketPosix::SetDefaultOptionsForServer() {
|
int TCPSocketPosix::SetDefaultOptionsForServer() {
|
||||||
DCHECK(socket_);
|
DCHECK(socket_);
|
||||||
|
|
||||||
|
#ifdef SO_REUSEPORT
|
||||||
|
int reuseport = 1;
|
||||||
|
int rv =
|
||||||
|
setsockopt(socket_->socket_fd(), SOL_SOCKET, SO_REUSEPORT,
|
||||||
|
reinterpret_cast<const char*>(&reuseport), sizeof(reuseport));
|
||||||
|
// Ignore errors that the option does not exist.
|
||||||
|
if (rv != 0 && errno != ENOPROTOOPT)
|
||||||
|
return MapSystemError(errno);
|
||||||
|
#endif // SO_REUSEPORT
|
||||||
|
|
||||||
return AllowAddressReuse();
|
return AllowAddressReuse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user