void DaemonMetadataIndex::insert(DaemonMetadataPtr dm)
{
- if (exists(dm->key)) {
+ Mutex::Locker l(lock);
+
+ if (all.count(dm->key)) {
_erase(dm->key);
}
DaemonMetadataCollection DaemonMetadataIndex::get_by_type(uint8_t type) const
{
+ Mutex::Locker l(lock);
+
DaemonMetadataCollection result;
for (const auto &i : all) {
DaemonMetadataCollection DaemonMetadataIndex::get_by_server(const std::string &hostname) const
{
+ Mutex::Locker l(lock);
+
if (by_server.count(hostname)) {
return by_server.at(hostname);
} else {
bool DaemonMetadataIndex::exists(const DaemonKey &key) const
{
+ Mutex::Locker l(lock);
+
return all.count(key) > 0;
}
DaemonMetadataPtr DaemonMetadataIndex::get(const DaemonKey &key)
{
+ Mutex::Locker l(lock);
+
return all.at(key);
}