mirror of https://github.com/Icinga/icinga2.git
parent
8b1579381e
commit
65e69fcd37
|
@ -65,6 +65,17 @@ ConnectionRole ApiClient::GetRole(void) const
|
|||
}
|
||||
|
||||
void ApiClient::SendMessage(const Dictionary::Ptr& message)
|
||||
{
|
||||
if (m_WriteQueue.GetLength() > 5000) {
|
||||
Log(LogWarning, "remote", "Closing connection for API identity '" + m_Identity + "': Too many queued messages.");
|
||||
Disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
m_WriteQueue.Enqueue(boost::bind(&ApiClient::SendMessageSync, this, message));
|
||||
}
|
||||
|
||||
void ApiClient::SendMessageSync(const Dictionary::Ptr& message)
|
||||
{
|
||||
try {
|
||||
ObjectLock olock(m_Stream);
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "remote/endpoint.hpp"
|
||||
#include "base/stream.hpp"
|
||||
#include "base/timer.hpp"
|
||||
#include "base/workqueue.hpp"
|
||||
#include "remote/i2-remote.hpp"
|
||||
|
||||
namespace icinga
|
||||
|
@ -64,8 +65,11 @@ private:
|
|||
ConnectionRole m_Role;
|
||||
double m_Seen;
|
||||
|
||||
WorkQueue m_WriteQueue;
|
||||
|
||||
bool ProcessMessage(void);
|
||||
void MessageThreadProc(void);
|
||||
void SendMessageSync(const Dictionary::Ptr& request);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -364,6 +364,10 @@ void ApiListener::ApiTimerHandler(void)
|
|||
if (endpoint->GetHost().IsEmpty() || endpoint->GetPort().IsEmpty())
|
||||
continue;
|
||||
|
||||
/* don't try to connect if there's already a connection attempt */
|
||||
if (endpoint->GetConnecting())
|
||||
continue;
|
||||
|
||||
Utility::QueueAsyncCallback(boost::bind(&ApiListener::AddConnection, this, endpoint));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue