1
0

Don't keep the read lock after traversing the items map (before saving to the io.Writer) in Save

This commit is contained in:
Patrick Mylund Nielsen 2013-06-30 20:20:38 -04:00
parent 5388b25b3b
commit 3986bff69b

View File

@ -876,11 +876,12 @@ func (c *cache) Save(w io.Writer) (err error) {
}
}()
c.RLock()
defer c.RUnlock()
for _, v := range c.items {
items := c.items
for _, v := range items {
gob.Register(v.Object)
}
err = enc.Encode(&c.items)
c.RUnlock()
err = enc.Encode(&items)
return
}