Support SO_REUSEPORT option
so that multiple osrm-routed processes can bind to the same port.
This commit is contained in:
parent
dcb741d827
commit
fe397e6953
@ -49,7 +49,12 @@ class Server
|
||||
boost::asio::ip::tcp::endpoint endpoint = *resolver.resolve(query);
|
||||
|
||||
acceptor.open(endpoint.protocol());
|
||||
#ifdef SO_REUSEPORT
|
||||
int one = 1;
|
||||
setsockopt(acceptor.native_handle(), SOL_SOCKET, SO_REUSEADDR | SO_REUSEPORT, &one, sizeof(one));
|
||||
#else
|
||||
acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
|
||||
#endif
|
||||
acceptor.bind(endpoint);
|
||||
acceptor.listen();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user