From 3986bff69b77c69cd3c04bc77032e631277b741c Mon Sep 17 00:00:00 2001 From: Patrick Mylund Nielsen Date: Sun, 30 Jun 2013 20:20:38 -0400 Subject: [PATCH] Don't keep the read lock after traversing the items map (before saving to the io.Writer) in Save --- cache.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cache.go b/cache.go index ef53abc..dd8de64 100644 --- a/cache.go +++ b/cache.go @@ -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 }