1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Fix bitsequence set()

- incorrect handling during datastore write

Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
Alessandro Boch 2015-09-04 18:15:54 -07:00
parent c712abd18e
commit 84a0a0a98f

View file

@ -252,9 +252,8 @@ func (h *Handle) set(ordinal uint32, any bool, release bool) (uint32, error) {
return ret, err 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() nh := h.getCopy()
ci := h.dbIndex
h.Unlock() h.Unlock()
nh.head = pushReservation(bytePos, bitPos, nh.head, release) 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 continue
} }
// Unless unexpected error, save private copy to local copy // Previous atomic push was succesfull. Save private copy to local copy
h.Lock() h.Lock()
defer h.Unlock() defer h.Unlock()
if h.dbIndex != ci {
return ret, fmt.Errorf("unexected database index change")
}
h.unselected = nh.unselected h.unselected = nh.unselected
h.head = nh.head h.head = nh.head
h.dbExists = nh.dbExists h.dbExists = nh.dbExists