Set the SO_REUSEPORT flag on OS X whenever we set the SO_REUSEADDR
This commit is contained in:
parent
0a11b29984
commit
eb501387e8
1 changed files with 16 additions and 0 deletions
|
|
@ -136,6 +136,14 @@ namespace fc {
|
||||||
FC_ASSERT(my->_sock.is_open());
|
FC_ASSERT(my->_sock.is_open());
|
||||||
boost::asio::socket_base::reuse_address option(enable);
|
boost::asio::socket_base::reuse_address option(enable);
|
||||||
my->_sock.set_option(option);
|
my->_sock.set_option(option);
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
// OSX needs SO_REUSEPORT in addition to SO_REUSEADDR.
|
||||||
|
// This probably needs to be set for any BSD
|
||||||
|
int reuseport_value = 1;
|
||||||
|
if (setsockopt(my->_sock.native(), SOL_SOCKET, SO_REUSEPORT,
|
||||||
|
(char*)&reuseport_value, sizeof(reuseport_value)) < 0)
|
||||||
|
wlog("Error setting SO_REUSEPORT");
|
||||||
|
#endif // __APPLE__
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -187,6 +195,14 @@ namespace fc {
|
||||||
my = new impl;
|
my = new impl;
|
||||||
boost::asio::ip::tcp::acceptor::reuse_address option(enable);
|
boost::asio::ip::tcp::acceptor::reuse_address option(enable);
|
||||||
my->_accept.set_option(option);
|
my->_accept.set_option(option);
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
// OSX needs SO_REUSEPORT in addition to SO_REUSEADDR.
|
||||||
|
// This probably needs to be set for any BSD
|
||||||
|
int reuseport_value = 1;
|
||||||
|
if (setsockopt(my->_accept.native(), SOL_SOCKET, SO_REUSEPORT,
|
||||||
|
(char*)&reuseport_value, sizeof(reuseport_value)) < 0)
|
||||||
|
wlog("Error setting SO_REUSEPORT");
|
||||||
|
#endif // __APPLE__
|
||||||
}
|
}
|
||||||
void tcp_server::listen( uint16_t port )
|
void tcp_server::listen( uint16_t port )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue