mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-28 16:14:09 +02:00
Fix: Icinga doesn't send SetLogPosition messages when one of the endpoints fails to connect
fixes #6537
This commit is contained in:
parent
c4bfff27c7
commit
adccc41a8d
@ -197,12 +197,11 @@ void ApiListener::ListenerThreadProc(const Socket::Ptr& server)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new JSON-RPC client and connects to the specified host and port.
|
* Creates a new JSON-RPC client and connects to the specified endpoint.
|
||||||
*
|
*
|
||||||
* @param node The remote host.
|
* @param endpoint The endpoint.
|
||||||
* @param service The remote port.
|
|
||||||
*/
|
*/
|
||||||
void ApiListener::AddConnection(const String& node, const String& service)
|
void ApiListener::AddConnection(const Endpoint::Ptr& endpoint)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
ObjectLock olock(this);
|
ObjectLock olock(this);
|
||||||
@ -215,14 +214,21 @@ void ApiListener::AddConnection(const String& node, const String& service)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String host = endpoint->GetHost();
|
||||||
|
String port = endpoint->GetPort();
|
||||||
|
|
||||||
TcpSocket::Ptr client = make_shared<TcpSocket>();
|
TcpSocket::Ptr client = make_shared<TcpSocket>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
client->Connect(node, service);
|
endpoint->SetConnecting(true);
|
||||||
Utility::QueueAsyncCallback(boost::bind(&ApiListener::NewClientHandler, this, client, RoleClient));
|
client->Connect(host, port);
|
||||||
|
NewClientHandler(client, RoleClient);
|
||||||
|
endpoint->SetConnecting(false);
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
|
endpoint->SetConnecting(false);
|
||||||
|
|
||||||
std::ostringstream info, debug;
|
std::ostringstream info, debug;
|
||||||
info << "Cannot connect to host '" << node << "' on port '" << service << "'";
|
info << "Cannot connect to host '" << host << "' on port '" << port << "'";
|
||||||
debug << info.str() << std::endl << DiagnosticInformation(ex);
|
debug << info.str() << std::endl << DiagnosticInformation(ex);
|
||||||
Log(LogCritical, "ApiListener", info.str());
|
Log(LogCritical, "ApiListener", info.str());
|
||||||
Log(LogDebug, "ApiListener", debug.str());
|
Log(LogDebug, "ApiListener", debug.str());
|
||||||
@ -358,7 +364,7 @@ void ApiListener::ApiTimerHandler(void)
|
|||||||
if (endpoint->GetHost().IsEmpty() || endpoint->GetPort().IsEmpty())
|
if (endpoint->GetHost().IsEmpty() || endpoint->GetPort().IsEmpty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
AddConnection(endpoint->GetHost(), endpoint->GetPort());
|
Utility::QueueAsyncCallback(boost::bind(&ApiListener::AddConnection, this, endpoint));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ private:
|
|||||||
void ApiTimerHandler(void);
|
void ApiTimerHandler(void);
|
||||||
|
|
||||||
void AddListener(const String& service);
|
void AddListener(const String& service);
|
||||||
void AddConnection(const String& node, const String& service);
|
void AddConnection(const Endpoint::Ptr& endpoint);
|
||||||
|
|
||||||
void NewClientHandler(const Socket::Ptr& client, ConnectionRole role);
|
void NewClientHandler(const Socket::Ptr& client, ConnectionRole role);
|
||||||
void ListenerThreadProc(const Socket::Ptr& server);
|
void ListenerThreadProc(const Socket::Ptr& server);
|
||||||
|
@ -16,6 +16,7 @@ class Endpoint : DynamicObject
|
|||||||
[state] double local_log_position;
|
[state] double local_log_position;
|
||||||
[state] double remote_log_position;
|
[state] double remote_log_position;
|
||||||
|
|
||||||
|
bool connecting;
|
||||||
bool syncing;
|
bool syncing;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user