mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-15 09:44:31 +02:00
Merge pull request #5581 from Icinga/fix/api-crash-race-condition
Fix possible race condition in ApiListener locking
This commit is contained in:
commit
77ecdbd85c
@ -1309,37 +1309,37 @@ double ApiListener::CalculateZoneLag(const Endpoint::Ptr& endpoint)
|
|||||||
|
|
||||||
void ApiListener::AddAnonymousClient(const JsonRpcConnection::Ptr& aclient)
|
void ApiListener::AddAnonymousClient(const JsonRpcConnection::Ptr& aclient)
|
||||||
{
|
{
|
||||||
ObjectLock olock(this);
|
boost::mutex::scoped_lock(m_AnonymousClientsLock);
|
||||||
m_AnonymousClients.insert(aclient);
|
m_AnonymousClients.insert(aclient);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApiListener::RemoveAnonymousClient(const JsonRpcConnection::Ptr& aclient)
|
void ApiListener::RemoveAnonymousClient(const JsonRpcConnection::Ptr& aclient)
|
||||||
{
|
{
|
||||||
ObjectLock olock(this);
|
boost::mutex::scoped_lock(m_AnonymousClientsLock);
|
||||||
m_AnonymousClients.erase(aclient);
|
m_AnonymousClients.erase(aclient);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<JsonRpcConnection::Ptr> ApiListener::GetAnonymousClients(void) const
|
std::set<JsonRpcConnection::Ptr> ApiListener::GetAnonymousClients(void) const
|
||||||
{
|
{
|
||||||
ObjectLock olock(this);
|
boost::mutex::scoped_lock(m_AnonymousClientsLock);
|
||||||
return m_AnonymousClients;
|
return m_AnonymousClients;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApiListener::AddHttpClient(const HttpServerConnection::Ptr& aclient)
|
void ApiListener::AddHttpClient(const HttpServerConnection::Ptr& aclient)
|
||||||
{
|
{
|
||||||
ObjectLock olock(this);
|
boost::mutex::scoped_lock(m_HttpClientsLock);
|
||||||
m_HttpClients.insert(aclient);
|
m_HttpClients.insert(aclient);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApiListener::RemoveHttpClient(const HttpServerConnection::Ptr& aclient)
|
void ApiListener::RemoveHttpClient(const HttpServerConnection::Ptr& aclient)
|
||||||
{
|
{
|
||||||
ObjectLock olock(this);
|
boost::mutex::scoped_lock(m_HttpClientsLock);
|
||||||
m_HttpClients.erase(aclient);
|
m_HttpClients.erase(aclient);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<HttpServerConnection::Ptr> ApiListener::GetHttpClients(void) const
|
std::set<HttpServerConnection::Ptr> ApiListener::GetHttpClients(void) const
|
||||||
{
|
{
|
||||||
ObjectLock olock(this);
|
boost::mutex::scoped_lock(m_HttpClientsLock);
|
||||||
return m_HttpClients;
|
return m_HttpClients;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,8 +115,12 @@ protected:
|
|||||||
private:
|
private:
|
||||||
boost::shared_ptr<SSL_CTX> m_SSLContext;
|
boost::shared_ptr<SSL_CTX> m_SSLContext;
|
||||||
std::set<TcpSocket::Ptr> m_Servers;
|
std::set<TcpSocket::Ptr> m_Servers;
|
||||||
|
|
||||||
|
mutable boost::mutex m_AnonymousClientsLock;
|
||||||
|
mutable boost::mutex m_HttpClientsLock;
|
||||||
std::set<JsonRpcConnection::Ptr> m_AnonymousClients;
|
std::set<JsonRpcConnection::Ptr> m_AnonymousClients;
|
||||||
std::set<HttpServerConnection::Ptr> m_HttpClients;
|
std::set<HttpServerConnection::Ptr> m_HttpClients;
|
||||||
|
|
||||||
Timer::Ptr m_Timer;
|
Timer::Ptr m_Timer;
|
||||||
Timer::Ptr m_ReconnectTimer;
|
Timer::Ptr m_ReconnectTimer;
|
||||||
Timer::Ptr m_AuthorityTimer;
|
Timer::Ptr m_AuthorityTimer;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user