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

@@ -21,8 +21,10 @@ import (
func (c *Cache) CreateServer(addr string) {
_, ok := c.Servers[addr]
if !ok {
c.ServersMutex.Lock()
c.Servers[addr] = &cachemodels.Server{}
c.Servers[addr].Server = &datamodels.Server{}
c.ServersMutex.Unlock()
} else {
fmt.Println("Server " + addr + " already exist.")
}