Skip to content

Commit 278cb8c

Browse files
committed
Fix committed thread safety
1 parent 0f802a9 commit 278cb8c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

trie/ctrie/ctrie.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ type rdcssDescriptor struct {
845845
old *iNode
846846
expected *mainNode
847847
nv *iNode
848-
committed bool
848+
committed int32
849849
}
850850

851851
// readRoot performs a linearizable read of the Ctrie root. This operation is
@@ -878,7 +878,7 @@ func (c *Ctrie) rdcssRoot(old *iNode, expected *mainNode, nv *iNode) bool {
878878
}
879879
if c.casRoot(old, desc) {
880880
c.rdcssComplete(false)
881-
return desc.rdcss.committed
881+
return atomic.LoadInt32(&desc.rdcss.committed) == 1
882882
}
883883
return false
884884
}
@@ -909,7 +909,7 @@ func (c *Ctrie) rdcssComplete(abort bool) *iNode {
909909
if oldeMain == exp {
910910
// Commit the RDCSS.
911911
if c.casRoot(r, nv) {
912-
desc.committed = true
912+
atomic.StoreInt32(&desc.committed, 1)
913913
return nv
914914
}
915915
continue

0 commit comments

Comments
 (0)