From: Gunnar Beutner Date: Thu, 19 Apr 2012 07:18:54 +0000 (+0200) Subject: Set SO_REUSEADDR for listeners. X-Git-Tag: v0.0.1~620 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8621717f4c5055b6549d3010227ae10f1693742d;p=icinga2 Set SO_REUSEADDR for listeners. --- diff --git a/base/tcpsocket.cpp b/base/tcpsocket.cpp index dc23176ca..1d8b6dcba 100644 --- a/base/tcpsocket.cpp +++ b/base/tcpsocket.cpp @@ -29,8 +29,12 @@ void TCPSocket::Bind(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)); sin.sin_family = AF_INET; sin.sin_addr.s_addr = hostname ? inet_addr(hostname) : htonl(INADDR_ANY); diff --git a/icinga/icingaapplication.cpp b/icinga/icingaapplication.cpp index a84023654..235d44292 100644 --- a/icinga/icingaapplication.cpp +++ b/icinga/icingaapplication.cpp @@ -67,7 +67,7 @@ int IcingaApplication::Main(const vector& args) m_TestEndpoint->RegisterMethodSource("test"); m_TestTimer = make_shared(); - m_TestTimer->SetInterval(5); + m_TestTimer->SetInterval(1); m_TestTimer->OnTimerExpired += bind_weak(&IcingaApplication::TestTimerHandler, shared_from_this()); m_TestTimer->Start(); @@ -84,7 +84,7 @@ int IcingaApplication::TestTimerHandler(const TimerEventArgs& tea) request.SetVersion("2.0"); request.SetMethod("test"); - for (int i = 0; i < 1000; i++) + for (int i = 0; i < 10000; i++) m_EndpointManager->SendMulticastRequest(m_TestEndpoint, request); return 0;