From 11ba94f4ab3076268202ec8c02a5c1fc81a93032 Mon Sep 17 00:00:00 2001 From: siddontang Date: Thu, 27 Nov 2014 20:48:55 +0800 Subject: [PATCH] fix issue #112 --- rpl/file_store.go | 7 ++++--- server/snapshot.go | 3 +-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/rpl/file_store.go b/rpl/file_store.go index 161ab8d..5f4c324 100644 --- a/rpl/file_store.go +++ b/rpl/file_store.go @@ -196,14 +196,15 @@ func (s *FileStore) storeLog(l *Log) error { func (s *FileStore) PurgeExpired(n int64) error { s.rm.Lock() - purges := []*tableReader{} + var purges []*tableReader t := uint32(time.Now().Unix() - int64(n)) for i, r := range s.rs { if r.lastTime > t { - purges = s.rs[0:i] - s.rs = s.rs[i:] + purges = append([]*tableReader{}, s.rs[0:i]...) + n := copy(s.rs, s.rs[i:]) + s.rs = s.rs[0:n] break } } diff --git a/server/snapshot.go b/server/snapshot.go index 67192ea..b238545 100644 --- a/server/snapshot.go +++ b/server/snapshot.go @@ -137,8 +137,7 @@ func (s *snapshotStore) purge(create bool) { } if num > 0 { - names = s.names[0:num] - + names = append([]string{}, s.names[0:num]...) n := copy(s.names, s.names[num:]) s.names = s.names[0:n] }