Fix races with concurrent GC
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
4
gc/gc.go
4
gc/gc.go
@@ -145,10 +145,10 @@ func ConcurrentMark(ctx context.Context, root <-chan Node, refs func(context.Con
|
||||
|
||||
// Sweep removes all nodes returned through the channel which are not in
|
||||
// the reachable set by calling the provided remove function.
|
||||
func Sweep(reachable map[Node]struct{}, all <-chan Node, remove func(Node) error) error {
|
||||
func Sweep(reachable map[Node]struct{}, all []Node, remove func(Node) error) error {
|
||||
// All black objects are now reachable, and all white objects are
|
||||
// unreachable. Free those that are white!
|
||||
for node := range all {
|
||||
for _, node := range all {
|
||||
if _, ok := reachable[node]; !ok {
|
||||
if err := remove(node); err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user