Fix {Host,Service,User}Group::{Add,Remove}Member isn't thread-safe.

Fixes #5699
This commit is contained in:
Michael Friedrich 2014-03-11 10:40:37 +01:00
parent 5e5c9285c9
commit 2b6529c424
6 changed files with 12 additions and 0 deletions

View File

@ -31,15 +31,18 @@ REGISTER_TYPE(HostGroup);
std::set<Host::Ptr> HostGroup::GetMembers(void) const
{
boost::mutex::scoped_lock lock(m_HostGroupMutex);
return m_Members;
}
void HostGroup::AddMember(const Host::Ptr& host)
{
boost::mutex::scoped_lock lock(m_HostGroupMutex);
m_Members.insert(host);
}
void HostGroup::RemoveMember(const Host::Ptr& host)
{
boost::mutex::scoped_lock lock(m_HostGroupMutex);
m_Members.erase(host);
}

View File

@ -43,6 +43,7 @@ public:
void RemoveMember(const Host::Ptr& host);
private:
mutable boost::mutex m_HostGroupMutex;
std::set<Host::Ptr> m_Members;
};

View File

@ -32,15 +32,18 @@ REGISTER_TYPE(ServiceGroup);
std::set<Service::Ptr> ServiceGroup::GetMembers(void) const
{
boost::mutex::scoped_lock lock(m_ServiceGroupMutex);
return m_Members;
}
void ServiceGroup::AddMember(const Service::Ptr& service)
{
boost::mutex::scoped_lock lock(m_ServiceGroupMutex);
m_Members.insert(service);
}
void ServiceGroup::RemoveMember(const Service::Ptr& service)
{
boost::mutex::scoped_lock lock(m_ServiceGroupMutex);
m_Members.erase(service);
}

View File

@ -43,6 +43,7 @@ public:
void RemoveMember(const Service::Ptr& service);
private:
mutable boost::mutex m_ServiceGroupMutex;
std::set<Service::Ptr> m_Members;
};

View File

@ -31,15 +31,18 @@ REGISTER_TYPE(UserGroup);
std::set<User::Ptr> UserGroup::GetMembers(void) const
{
boost::mutex::scoped_lock lock(m_UserGroupMutex);
return m_Members;
}
void UserGroup::AddMember(const User::Ptr& user)
{
boost::mutex::scoped_lock lock(m_UserGroupMutex);
m_Members.insert(user);
}
void UserGroup::RemoveMember(const User::Ptr& user)
{
boost::mutex::scoped_lock lock(m_UserGroupMutex);
m_Members.erase(user);
}

View File

@ -43,6 +43,7 @@ public:
void RemoveMember(const User::Ptr& user);
private:
mutable boost::mutex m_UserGroupMutex;
std::set<User::Ptr> m_Members;
};