Skip to content

Commit

Permalink
Moved Absorb critical section to be the entire function
Browse files Browse the repository at this point in the history
  • Loading branch information
lkarlslund committed Nov 10, 2022
1 parent 0ab9fd1 commit 8905e42
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions modules/engine/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ func (target *Object) AbsorbEx(source *Object, fast bool) {
// Keep normies out
target.lockwith(source)

absorbCriticalSection.Lock()

if !source.status.CompareAndSwap(1, 2) {
// We're being absorbed, nom nom
panic("Can only absorb valid objects")
Expand All @@ -161,7 +163,6 @@ func (target *Object) AbsorbEx(source *Object, fast bool) {
}

// fmt.Println("----------------------------------------")
absorbCriticalSection.Lock()
ongoingAbsorbs.Store(source, target)
source.edges[Out].Range(func(outgoingTarget *Object, edges EdgeBitmap) bool {
if source == outgoingTarget {
Expand Down Expand Up @@ -272,7 +273,6 @@ func (target *Object) AbsorbEx(source *Object, fast bool) {
}

ongoingAbsorbs.Delete(source)
absorbCriticalSection.Unlock()

// Move the securitydescriptor, as we dont have the attribute saved to regenerate it (we throw it away at import after populating the cache)
if source.sdcache != nil && target.sdcache != nil {
Expand All @@ -292,6 +292,8 @@ func (target *Object) AbsorbEx(source *Object, fast bool) {
panic("Unpossible absorption mutation occurred")
}

absorbCriticalSection.Unlock()

target.unlockwith(source)
}

Expand Down

0 comments on commit 8905e42

Please sign in to comment.