From 1432497d5b4776468c5b8b142324b3881ddf5f7d Mon Sep 17 00:00:00 2001 From: Nicholas Wiersma Date: Tue, 15 Jan 2019 16:40:41 +0200 Subject: [PATCH] Grab the metadata after lock (#39) --- metastore.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/metastore.go b/metastore.go index 9b34677..eabe6f7 100644 --- a/metastore.go +++ b/metastore.go @@ -94,8 +94,6 @@ func (s *metastore) Mark(p Processor, src Source, meta Metadata) error { return nil } - procMeta := s.metadata.Load().(*map[Processor]Metaitems) - if meta != nil { o := ProcessorOrigin if _, ok := p.(Committer); ok { @@ -104,8 +102,11 @@ func (s *metastore) Mark(p Processor, src Source, meta Metadata) error { meta.WithOrigin(o) } - + s.procMu.Lock() + + procMeta := s.metadata.Load().(*map[Processor]Metaitems) + items, ok := (*procMeta)[p] if !ok { (*procMeta)[p] = Metaitems{{Source: src, Metadata: meta}}