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

master
Patrick Mylund Nielsen 12 years ago
parent 5388b25b3b
commit 3986bff69b

@ -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
} }

Loading…
Cancel
Save