Skip to content

Commit

Permalink
Fix indentation in topoSort
Browse files Browse the repository at this point in the history
  • Loading branch information
jhiemstrawisc committed Dec 17, 2024
1 parent 4816b66 commit 45968af
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions lotman/lotman_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -735,36 +735,36 @@ func configLotsFromFedPrefixes(nsAds []server_structs.NamespaceAdV2) (map[string
// this means we have to sort our lots topologically to ensure that we create them in the correct order.
// Failure to do so appears to result in a segfault in Lotman.
func topoSort(lotMap map[string]Lot) ([]Lot, error) {
sorted := make([]Lot, 0, len(lotMap))
visited := make(map[string]bool)
sorted := make([]Lot, 0, len(lotMap))
visited := make(map[string]bool)

// Recursively visit each lot and its parents, DFS-style
var visit func(string) error
visit = func(name string) error {
if visited[name] {
return nil
}
visited[name] = true
visit = func(name string) error {
if visited[name] {
return nil
}
visited[name] = true

// Visit all parents first
for _, parent := range lotMap[name].Parents {
if err := visit(parent); err != nil {
return err
}
}
// Visit all parents first
for _, parent := range lotMap[name].Parents {
if err := visit(parent); err != nil {
return err
}
}
// Adding the leaves of the DFS parent tree to the sorted list
// guarantees that we'll add the parents before the children
sorted = append(sorted, lotMap[name])
return nil
}
sorted = append(sorted, lotMap[name])
return nil
}

for name := range lotMap {
if err := visit(name); err != nil {
return nil, err
}
}
for name := range lotMap {
if err := visit(name); err != nil {
return nil, err
}
}

return sorted, nil
return sorted, nil
}


Expand Down

0 comments on commit 45968af

Please sign in to comment.