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
1 changed files with 4 additions and 3 deletions

View File

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