All caches is now protected with mutexes.

This commit is contained in:
2016-12-13 04:58:31 +05:00
parent 384754276a
commit 2997abf1aa
3 changed files with 11 additions and 0 deletions

View File

@@ -24,8 +24,10 @@ func (c *Cache) CreateProfile(name string) {
_, ok := c.Profiles[name]
if !ok {
c.ProfilesMutex.Lock()
c.Profiles[name] = &cachemodels.Profile{}
c.Profiles[name].Profile = &datamodels.Profile{}
c.ProfilesMutex.Unlock()
}
}
@@ -34,7 +36,9 @@ func (c *Cache) deleteProfile(data map[string]string) {
_, ok := c.Profiles[data["profile_name"]]
if ok {
c.ProfilesMutex.Lock()
delete(c.Profiles, data["profile_name"])
c.ProfilesMutex.Unlock()
}
_, ok1 := c.Profiles[data["profile_name"]]