mirror of https://github.com/Icinga/icinga2.git
parent
f43516a097
commit
2fec16952d
|
@ -192,27 +192,8 @@ void JsonRpcConnection::MessageHandler(const String& jsonString)
|
|||
if (!message->Get("id", &vid))
|
||||
return;
|
||||
|
||||
String id = vid;
|
||||
|
||||
ApiCallbackInfo aci;
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_ApiCallbacksMutex);
|
||||
auto it = m_ApiCallbacks.find(id);
|
||||
|
||||
if (it == m_ApiCallbacks.end())
|
||||
return;
|
||||
|
||||
aci = it->second;
|
||||
m_ApiCallbacks.erase(it);
|
||||
}
|
||||
|
||||
try {
|
||||
aci.Callback(message);
|
||||
} catch (const std::exception& ex) {
|
||||
Log(LogWarning, "JsonRpcConnection")
|
||||
<< "Error while processing message for identity '" << m_Identity << "'\n" << DiagnosticInformation(ex);
|
||||
}
|
||||
Log(LogWarning, "JsonRpcConnection",
|
||||
"We received a JSON-RPC response message. This should never happen because we're only ever sending notifications.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -306,11 +287,6 @@ Value SetLogPositionHandler(const MessageOrigin::Ptr& origin, const Dictionary::
|
|||
return Empty;
|
||||
}
|
||||
|
||||
bool ApiCallbackInfo::IsExpired(void) const
|
||||
{
|
||||
return Timestamp < Utility::GetTime() - 300;
|
||||
}
|
||||
|
||||
void JsonRpcConnection::CheckLiveness(void)
|
||||
{
|
||||
if (m_Seen < Utility::GetTime() - 60 && (!m_Endpoint || !m_Endpoint->GetSyncing())) {
|
||||
|
@ -318,18 +294,6 @@ void JsonRpcConnection::CheckLiveness(void)
|
|||
<< "No messages for identity '" << m_Identity << "' have been received in the last 60 seconds.";
|
||||
Disconnect();
|
||||
}
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_ApiCallbacksMutex);
|
||||
|
||||
for (auto it = m_ApiCallbacks.begin(), last = m_ApiCallbacks.end(); it != last; ) {
|
||||
if (it->second.IsExpired()) {
|
||||
it = m_ApiCallbacks.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void JsonRpcConnection::TimeoutTimerHandler(void)
|
||||
|
@ -379,14 +343,3 @@ double JsonRpcConnection::GetWorkQueueRate(void)
|
|||
return rate / count;
|
||||
}
|
||||
|
||||
void JsonRpcConnection::RegisterCallback(const String& id, const boost::function<void (const Dictionary::Ptr&)>& callback)
|
||||
{
|
||||
ApiCallbackInfo aci;
|
||||
aci.Timestamp = Utility::GetTime();
|
||||
aci.Callback = callback;
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_ApiCallbacksMutex);
|
||||
m_ApiCallbacks[id] = aci;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,14 +43,6 @@ enum ClientType
|
|||
|
||||
class MessageOrigin;
|
||||
|
||||
struct ApiCallbackInfo
|
||||
{
|
||||
double Timestamp;
|
||||
boost::function<void (const Dictionary::Ptr&)> Callback;
|
||||
|
||||
bool IsExpired(void) const;
|
||||
};
|
||||
|
||||
/**
|
||||
* An API client connection.
|
||||
*
|
||||
|
@ -97,8 +89,6 @@ private:
|
|||
double m_NextHeartbeat;
|
||||
double m_HeartbeatTimeout;
|
||||
boost::mutex m_DataHandlerMutex;
|
||||
std::map<String, ApiCallbackInfo> m_ApiCallbacks;
|
||||
boost::mutex m_ApiCallbacksMutex;
|
||||
|
||||
StreamReadContext m_Context;
|
||||
|
||||
|
@ -111,8 +101,6 @@ private:
|
|||
static void TimeoutTimerHandler(void);
|
||||
void CheckLiveness(void);
|
||||
|
||||
void RegisterCallback(const String& id, const boost::function<void (const Dictionary::Ptr&)>& callback);
|
||||
|
||||
void CertificateRequestResponseHandler(const Dictionary::Ptr& message);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue