mirror of https://github.com/Icinga/icinga2.git
Bugfix: duplicate Welcome messages
This commit is contained in:
parent
8a5e1423ca
commit
63e318383d
|
@ -198,12 +198,12 @@ int DiscoveryComponent::WelcomeMessageHandler(const NewRequestEventArgs& nrea)
|
|||
{
|
||||
Endpoint::Ptr endpoint = nrea.Sender;
|
||||
|
||||
if (endpoint->GetHandshakeCounter() >= 2)
|
||||
if (endpoint->GetReceivedWelcome())
|
||||
return 0;
|
||||
|
||||
endpoint->IncrementHandshakeCounter();
|
||||
endpoint->SetReceivedWelcome(true);
|
||||
|
||||
if (endpoint->GetHandshakeCounter() >= 2) {
|
||||
if (endpoint->GetSentWelcome()) {
|
||||
EventArgs ea;
|
||||
ea.Source = shared_from_this();
|
||||
endpoint->OnSessionEstablished(ea);
|
||||
|
@ -214,7 +214,7 @@ int DiscoveryComponent::WelcomeMessageHandler(const NewRequestEventArgs& nrea)
|
|||
|
||||
void DiscoveryComponent::FinishDiscoverySetup(Endpoint::Ptr endpoint)
|
||||
{
|
||||
if (endpoint->GetHandshakeCounter() >= 2)
|
||||
if (endpoint->GetSentWelcome())
|
||||
return;
|
||||
|
||||
// we assume the other component _always_ wants
|
||||
|
@ -224,6 +224,8 @@ void DiscoveryComponent::FinishDiscoverySetup(Endpoint::Ptr endpoint)
|
|||
request.SetMethod("discovery::Welcome");
|
||||
GetEndpointManager()->SendUnicastRequest(m_DiscoveryEndpoint, endpoint, request);
|
||||
|
||||
endpoint->SetSentWelcome(true);
|
||||
|
||||
ComponentDiscoveryInfo::Ptr info;
|
||||
|
||||
if (GetComponentDiscoveryInfo(endpoint->GetIdentity(), &info)) {
|
||||
|
@ -235,9 +237,7 @@ void DiscoveryComponent::FinishDiscoverySetup(Endpoint::Ptr endpoint)
|
|||
endpoint->RegisterMethodSink(*i);
|
||||
}
|
||||
|
||||
endpoint->IncrementHandshakeCounter();
|
||||
|
||||
if (endpoint->GetHandshakeCounter() >= 2) {
|
||||
if (endpoint->GetReceivedWelcome()) {
|
||||
EventArgs ea;
|
||||
ea.Source = shared_from_this();
|
||||
endpoint->OnSessionEstablished(ea);
|
||||
|
@ -417,6 +417,7 @@ int DiscoveryComponent::DiscoveryTimerHandler(const TimerEventArgs& tea)
|
|||
/* update LastSeen if we're still connected to this endpoint */
|
||||
info->LastSeen = now;
|
||||
} else {
|
||||
/* TODO: figure out whether we actually want to connect to this component (_always_ if IsBroker() == true) */
|
||||
/* try and reconnect to this component */
|
||||
endpointManager->AddConnection(info->Node, info->Service);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,6 @@
|
|||
"kekslistener": { "replicate": "0", "service": "8888" }
|
||||
},
|
||||
"broker": {
|
||||
"icinga-c1": { "replicate": "0", "node": "127.0.0.1", "service": "7777" }
|
||||
"icinga-c1": { "replicate": "0", "node": "10.0.10.3", "service": "7777" }
|
||||
}
|
||||
}
|
|
@ -4,7 +4,8 @@ using namespace icinga;
|
|||
|
||||
Endpoint::Endpoint(void)
|
||||
{
|
||||
m_HandshakeCounter = false;
|
||||
m_ReceivedWelcome = false;
|
||||
m_SentWelcome = false;
|
||||
}
|
||||
|
||||
string Endpoint::GetIdentity(void) const
|
||||
|
@ -126,12 +127,22 @@ set<string>::const_iterator Endpoint::EndSources(void) const
|
|||
return m_MethodSources.end();
|
||||
}
|
||||
|
||||
void Endpoint::IncrementHandshakeCounter(void)
|
||||
void Endpoint::SetReceivedWelcome(bool value)
|
||||
{
|
||||
m_HandshakeCounter++;
|
||||
m_ReceivedWelcome = value;
|
||||
}
|
||||
|
||||
unsigned short Endpoint::GetHandshakeCounter(void) const
|
||||
bool Endpoint::GetReceivedWelcome(void) const
|
||||
{
|
||||
return m_HandshakeCounter;
|
||||
return m_ReceivedWelcome;
|
||||
}
|
||||
|
||||
void Endpoint::SetSentWelcome(bool value)
|
||||
{
|
||||
m_SentWelcome = value;
|
||||
}
|
||||
|
||||
bool Endpoint::GetSentWelcome(void) const
|
||||
{
|
||||
return m_SentWelcome;
|
||||
}
|
|
@ -17,7 +17,8 @@ private:
|
|||
string m_Identity;
|
||||
set<string> m_MethodSinks;
|
||||
set<string> m_MethodSources;
|
||||
unsigned short m_HandshakeCounter;
|
||||
bool m_ReceivedWelcome;
|
||||
bool m_SentWelcome;
|
||||
|
||||
weak_ptr<EndpointManager> m_EndpointManager;
|
||||
|
||||
|
@ -33,8 +34,11 @@ public:
|
|||
void SetIdentity(string identity);
|
||||
bool HasIdentity(void) const;
|
||||
|
||||
void IncrementHandshakeCounter();
|
||||
unsigned short GetHandshakeCounter(void) const;
|
||||
void SetReceivedWelcome(bool value);
|
||||
bool GetReceivedWelcome(void) const;
|
||||
|
||||
void SetSentWelcome(bool value);
|
||||
bool GetSentWelcome(void) const;
|
||||
|
||||
shared_ptr<EndpointManager> GetEndpointManager(void) const;
|
||||
void SetEndpointManager(weak_ptr<EndpointManager> manager);
|
||||
|
|
Loading…
Reference in New Issue