mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 21:55:03 +02:00
parent
8b1579381e
commit
65e69fcd37
@ -65,6 +65,17 @@ ConnectionRole ApiClient::GetRole(void) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ApiClient::SendMessage(const Dictionary::Ptr& message)
|
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 {
|
try {
|
||||||
ObjectLock olock(m_Stream);
|
ObjectLock olock(m_Stream);
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "remote/endpoint.hpp"
|
#include "remote/endpoint.hpp"
|
||||||
#include "base/stream.hpp"
|
#include "base/stream.hpp"
|
||||||
#include "base/timer.hpp"
|
#include "base/timer.hpp"
|
||||||
|
#include "base/workqueue.hpp"
|
||||||
#include "remote/i2-remote.hpp"
|
#include "remote/i2-remote.hpp"
|
||||||
|
|
||||||
namespace icinga
|
namespace icinga
|
||||||
@ -64,8 +65,11 @@ private:
|
|||||||
ConnectionRole m_Role;
|
ConnectionRole m_Role;
|
||||||
double m_Seen;
|
double m_Seen;
|
||||||
|
|
||||||
|
WorkQueue m_WriteQueue;
|
||||||
|
|
||||||
bool ProcessMessage(void);
|
bool ProcessMessage(void);
|
||||||
void MessageThreadProc(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())
|
if (endpoint->GetHost().IsEmpty() || endpoint->GetPort().IsEmpty())
|
||||||
continue;
|
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));
|
Utility::QueueAsyncCallback(boost::bind(&ApiListener::AddConnection, this, endpoint));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user