From 71f57e33b9342790b6218abd063c339018822f07 Mon Sep 17 00:00:00 2001 From: Alessandro Boch Date: Fri, 4 Sep 2015 18:15:54 -0700 Subject: [PATCH] Fix bitsequence set() - incorrect handling during datastore write Signed-off-by: Alessandro Boch --- bitseq/sequence.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/bitseq/sequence.go b/bitseq/sequence.go index d71d76b..68acc44 100644 --- a/bitseq/sequence.go +++ b/bitseq/sequence.go @@ -252,9 +252,8 @@ func (h *Handle) set(ordinal uint32, any bool, release bool) (uint32, error) { return ret, err } - // Create a private copy of h and work on it, also copy the current db index + // Create a private copy of h and work on it nh := h.getCopy() - ci := h.dbIndex h.Unlock() nh.head = pushReservation(bytePos, bitPos, nh.head, release) @@ -273,12 +272,9 @@ func (h *Handle) set(ordinal uint32, any bool, release bool) (uint32, error) { continue } - // Unless unexpected error, save private copy to local copy + // Previous atomic push was succesfull. Save private copy to local copy h.Lock() defer h.Unlock() - if h.dbIndex != ci { - return ret, fmt.Errorf("unexected database index change") - } h.unselected = nh.unselected h.head = nh.head h.dbExists = nh.dbExists