Skip to content

Commit

Permalink
fix deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
Zylphrex committed Sep 26, 2023
1 parent 525b72b commit c609910
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
3 changes: 2 additions & 1 deletion internal/nodetree/nodetree.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,10 @@ func (n *Node) Close(timestamp uint64) {

func FindNodeByFingerprint(target uint32, nodes []*Node) *Node {
for _, node := range nodes {
if node.Frame.Fingerprint() != target {
if node.Frame.Fingerprint() == target {
return node
}

node := FindNodeByFingerprint(target, node.Children)
if node != nil {
return node
Expand Down
1 change: 1 addition & 0 deletions internal/occurrence/occurrence.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ func FromRegressedFunction(p profile.Profile, regressed RegressedFunction, f fra
ProjectID: regressed.ProjectID,
Received: now,
Timestamp: now,
Tags: make(map[string]string),
},
EvidenceData: map[string]interface{}{
"organization_id": regressed.OrganizationID,
Expand Down
22 changes: 12 additions & 10 deletions internal/occurrence/regressed_frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,18 @@ func ProcessRegressedFunctions(
}()
}

for _, regressedFunction := range regressedFunctions {
regressedChan <- regressedFunction
}
close(regressedChan)

// wait until all the profiles have been processed
// then we can close the occurrence channel and collect
// any occurrences that have been created
wg.Wait()
close(occurrenceChan)
go func() {
for _, regressedFunction := range regressedFunctions {
regressedChan <- regressedFunction
}
close(regressedChan)

// wait until all the profiles have been processed
// then we can close the occurrence channel and collect
// any occurrences that have been created
wg.Wait()
close(occurrenceChan)
}()

occurrences := []*Occurrence{}
for occurrence := range occurrenceChan {
Expand Down

0 comments on commit c609910

Please sign in to comment.