From efc3f3af29f233ce1d691a458af0b40a1961a155 Mon Sep 17 00:00:00 2001 From: Eric Coissac Date: Tue, 17 Jun 2025 12:05:42 +0200 Subject: [PATCH] Patch a concurrent access problem --- pkg/obioptions/version.go | 2 +- pkg/obiseq/merge.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/obioptions/version.go b/pkg/obioptions/version.go index f2b2585..d06fd67 100644 --- a/pkg/obioptions/version.go +++ b/pkg/obioptions/version.go @@ -8,7 +8,7 @@ import ( // corresponds to the last commit, and not the one when the file will be // commited -var _Commit = "38dcd98" +var _Commit = "1c6ab1c" var _Version = "Release 4.4.0" // Version returns the version of the obitools package. diff --git a/pkg/obiseq/merge.go b/pkg/obiseq/merge.go index 98827ed..be598fa 100644 --- a/pkg/obiseq/merge.go +++ b/pkg/obiseq/merge.go @@ -174,12 +174,15 @@ func (sequence *BioSequence) StatsPlusOne(desc StatsOnDescription, toAdd *BioSeq } + sequence.annot_lock.Lock() old, ok := stats[sval] if !ok { old = 0 } stats[sval] = old + desc.Weight(toAdd) + sequence.annot_lock.Unlock() + sequence.SetAttribute(StatsOnSlotName(desc.Name), stats) // TODO: check if this is necessary return retval } @@ -228,7 +231,9 @@ func (sequence *BioSequence) Merge(tomerge *BioSequence, na string, inplace bool smk := sequence.StatsOn(desc, na) mmk := tomerge.StatsOn(desc, na) + sequence.annot_lock.Lock() annotations[StatsOnSlotName(key)] = smk.Merge(mmk) + sequence.annot_lock.Unlock() } else { sequence.StatsPlusOne(desc, tomerge, na) }