mirror of https://github.com/Icinga/icinga2.git
Set SO_REUSEADDR for listeners.
This commit is contained in:
parent
810a8215e6
commit
8621717f4c
|
@ -29,8 +29,12 @@ void TCPSocket::Bind(unsigned short port)
|
||||||
|
|
||||||
void TCPSocket::Bind(const char *hostname, unsigned short port)
|
void TCPSocket::Bind(const char *hostname, unsigned short port)
|
||||||
{
|
{
|
||||||
sockaddr_in sin;
|
#ifndef _WIN32
|
||||||
|
const int optTrue = 1;
|
||||||
|
setsockopt(GetFD(), SOL_SOCKET, SO_REUSEADDR, (char *)&optTrue, sizeof(optTrue));
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
sockaddr_in sin;
|
||||||
memset(&sin, 0, sizeof(sin));
|
memset(&sin, 0, sizeof(sin));
|
||||||
sin.sin_family = AF_INET;
|
sin.sin_family = AF_INET;
|
||||||
sin.sin_addr.s_addr = hostname ? inet_addr(hostname) : htonl(INADDR_ANY);
|
sin.sin_addr.s_addr = hostname ? inet_addr(hostname) : htonl(INADDR_ANY);
|
||||||
|
|
|
@ -67,7 +67,7 @@ int IcingaApplication::Main(const vector<string>& args)
|
||||||
m_TestEndpoint->RegisterMethodSource("test");
|
m_TestEndpoint->RegisterMethodSource("test");
|
||||||
|
|
||||||
m_TestTimer = make_shared<Timer>();
|
m_TestTimer = make_shared<Timer>();
|
||||||
m_TestTimer->SetInterval(5);
|
m_TestTimer->SetInterval(1);
|
||||||
m_TestTimer->OnTimerExpired += bind_weak(&IcingaApplication::TestTimerHandler, shared_from_this());
|
m_TestTimer->OnTimerExpired += bind_weak(&IcingaApplication::TestTimerHandler, shared_from_this());
|
||||||
m_TestTimer->Start();
|
m_TestTimer->Start();
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ int IcingaApplication::TestTimerHandler(const TimerEventArgs& tea)
|
||||||
request.SetVersion("2.0");
|
request.SetVersion("2.0");
|
||||||
request.SetMethod("test");
|
request.SetMethod("test");
|
||||||
|
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 10000; i++)
|
||||||
m_EndpointManager->SendMulticastRequest(m_TestEndpoint, request);
|
m_EndpointManager->SendMulticastRequest(m_TestEndpoint, request);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue