Remove race conditions when accessing the last chunk

This commit is contained in:
Junegunn Choi
2015-01-04 05:01:13 +09:00
parent 0dd024a09f
commit d2f7acbc69
3 changed files with 36 additions and 20 deletions

View File

@@ -90,8 +90,9 @@ func Run(options *Options) {
})
}
snapshot, _ := chunkList.Snapshot()
matches, cancelled := matcher.scan(MatchRequest{
chunks: chunkList.Snapshot(),
chunks: snapshot,
pattern: pattern}, limit)
if !cancelled && (filtering ||
@@ -127,11 +128,13 @@ func Run(options *Options) {
case EVT_READ_NEW, EVT_READ_FIN:
reading = reading && evt == EVT_READ_NEW
terminal.UpdateCount(chunkList.Count(), !reading)
matcher.Reset(chunkList.Snapshot(), terminal.Input(), false)
snapshot, count := chunkList.Snapshot()
terminal.UpdateCount(count, !reading)
matcher.Reset(snapshot, terminal.Input(), false)
case EVT_SEARCH_NEW:
matcher.Reset(chunkList.Snapshot(), terminal.Input(), true)
snapshot, _ := chunkList.Snapshot()
matcher.Reset(snapshot, terminal.Input(), true)
delay = false
case EVT_SEARCH_PROGRESS: