mirror of https://github.com/Icinga/icinga2.git
Bug fixes for the new cache code.
This commit is contained in:
parent
d666960fa0
commit
e98fd3e3eb
|
@ -438,6 +438,9 @@ void CompatComponent::DumpServiceObject(ostream& fp, const Service::Ptr& service
|
|||
short_name = service->GetShortName();
|
||||
}
|
||||
|
||||
if (!host)
|
||||
return;
|
||||
|
||||
{
|
||||
ObjectLock olock(host);
|
||||
host_name = host->GetName();
|
||||
|
|
|
@ -23,7 +23,7 @@ using namespace icinga;
|
|||
|
||||
boost::mutex Host::m_ServiceMutex;
|
||||
map<String, map<String, weak_ptr<Service> > > Host::m_ServicesCache;
|
||||
bool Host::m_ServicesCacheValid = false;
|
||||
bool Host::m_ServicesCacheValid = true;
|
||||
|
||||
REGISTER_SCRIPTFUNCTION("ValidateServiceDictionary", &Host::ValidateServiceDictionary);
|
||||
|
||||
|
@ -57,6 +57,7 @@ void Host::OnRegistrationCompleted(void)
|
|||
{
|
||||
DynamicObject::OnRegistrationCompleted();
|
||||
|
||||
Host::InvalidateServicesCache();
|
||||
Host::UpdateSlaveServices(GetSelf());
|
||||
}
|
||||
|
||||
|
@ -75,9 +76,6 @@ Host::Ptr Host::GetByName(const String& name)
|
|||
{
|
||||
DynamicObject::Ptr configObject = DynamicObject::GetObject("Host", name);
|
||||
|
||||
if (!configObject)
|
||||
BOOST_THROW_EXCEPTION(invalid_argument("Host '" + name + "' does not exist."));
|
||||
|
||||
return dynamic_pointer_cast<Host>(configObject);
|
||||
}
|
||||
|
||||
|
@ -324,10 +322,12 @@ void Host::InvalidateServicesCache(void)
|
|||
{
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_ServiceMutex);
|
||||
|
||||
if (m_ServicesCacheValid)
|
||||
Utility::QueueAsyncCallback(boost::bind(&Host::RefreshServicesCache));
|
||||
|
||||
m_ServicesCacheValid = false;
|
||||
}
|
||||
|
||||
Utility::QueueAsyncCallback(boost::bind(&Host::RefreshServicesCache));
|
||||
}
|
||||
|
||||
void Host::RefreshServicesCache(void)
|
||||
|
@ -355,6 +355,9 @@ void Host::RefreshServicesCache(void)
|
|||
short_name = service->GetShortName();
|
||||
}
|
||||
|
||||
if (!host)
|
||||
continue;
|
||||
|
||||
String host_name;
|
||||
|
||||
{
|
||||
|
|
|
@ -107,10 +107,12 @@ void HostGroup::InvalidateMembersCache(void)
|
|||
{
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_Mutex);
|
||||
|
||||
if (m_MembersCacheValid)
|
||||
Utility::QueueAsyncCallback(boost::bind(&HostGroup::RefreshMembersCache));
|
||||
|
||||
m_MembersCacheValid = false;
|
||||
}
|
||||
|
||||
Utility::QueueAsyncCallback(boost::bind(&HostGroup::RefreshMembersCache));
|
||||
}
|
||||
|
||||
void HostGroup::RefreshMembersCache(void)
|
||||
|
|
|
@ -140,10 +140,12 @@ void Service::InvalidateCommentsCache(void)
|
|||
{
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_CommentMutex);
|
||||
|
||||
if (m_CommentsCacheValid)
|
||||
Utility::QueueAsyncCallback(boost::bind(&Service::RefreshCommentsCache));
|
||||
|
||||
m_CommentsCacheValid = false;
|
||||
}
|
||||
|
||||
Utility::QueueAsyncCallback(boost::bind(&Service::RefreshCommentsCache));
|
||||
}
|
||||
|
||||
void Service::RefreshCommentsCache(void)
|
||||
|
|
|
@ -217,10 +217,12 @@ void Service::InvalidateDowntimesCache(void)
|
|||
{
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_DowntimeMutex);
|
||||
|
||||
if (m_DowntimesCacheValid)
|
||||
Utility::QueueAsyncCallback(boost::bind(&Service::RefreshDowntimesCache));
|
||||
|
||||
m_DowntimesCacheValid = false;
|
||||
}
|
||||
|
||||
Utility::QueueAsyncCallback(boost::bind(&Service::RefreshDowntimesCache));
|
||||
}
|
||||
|
||||
void Service::RefreshDowntimesCache(void)
|
||||
|
|
|
@ -83,10 +83,12 @@ void Service::InvalidateNotificationsCache(void)
|
|||
{
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_NotificationMutex);
|
||||
|
||||
if (m_NotificationsCacheValid)
|
||||
Utility::QueueAsyncCallback(boost::bind(&Service::RefreshNotificationsCache));
|
||||
|
||||
m_NotificationsCacheValid = false;
|
||||
}
|
||||
|
||||
Utility::QueueAsyncCallback(boost::bind(&Service::RefreshNotificationsCache));
|
||||
}
|
||||
|
||||
void Service::RefreshNotificationsCache(void)
|
||||
|
|
|
@ -79,8 +79,6 @@ Service::~Service(void)
|
|||
void Service::OnRegistrationCompleted(void)
|
||||
{
|
||||
DynamicObject::OnRegistrationCompleted();
|
||||
|
||||
Host::InvalidateServicesCache();
|
||||
}
|
||||
|
||||
String Service::GetDisplayName(void) const
|
||||
|
|
|
@ -107,10 +107,12 @@ void ServiceGroup::InvalidateMembersCache(void)
|
|||
{
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_Mutex);
|
||||
|
||||
if (m_MembersCacheValid)
|
||||
Utility::QueueAsyncCallback(boost::bind(&ServiceGroup::RefreshMembersCache));
|
||||
|
||||
m_MembersCacheValid = false;
|
||||
}
|
||||
|
||||
Utility::QueueAsyncCallback(boost::bind(&ServiceGroup::RefreshMembersCache));
|
||||
}
|
||||
|
||||
void ServiceGroup::RefreshMembersCache(void)
|
||||
|
|
|
@ -33,9 +33,6 @@ User::Ptr User::GetByName(const String& name)
|
|||
{
|
||||
DynamicObject::Ptr configObject = DynamicObject::GetObject("User", name);
|
||||
|
||||
if (!configObject)
|
||||
BOOST_THROW_EXCEPTION(invalid_argument("User '" + name + "' does not exist."));
|
||||
|
||||
return dynamic_pointer_cast<User>(configObject);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue