1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-25 14:46:57 +00:00

Try to address goroutine leak in subscribe

This commit is contained in:
Darren Shepherd
2017-12-29 15:08:05 -07:00
parent 9ea843806b
commit b8622b9c90

View File

@@ -120,29 +120,15 @@ func streamStore(ctx context.Context, eg *errgroup.Group, apiContext *types.APIC
eg.Go(func() error { eg.Go(func() error {
opts := parse.QueryOptions(apiContext, schema) opts := parse.QueryOptions(apiContext, schema)
events, err := schema.Store.Watch(apiContext, schema, &opts) events, err := schema.Store.Watch(apiContext, schema, &opts)
if err != nil { if err != nil || events == nil {
return err return err
} }
if events == nil { for e := range events {
return nil result <- e
} }
for { return nil
select {
case e, ok := <-events:
if !ok {
return nil
}
select {
case result <- e:
case <-ctx.Done():
return ctx.Err()
}
case <-ctx.Done():
return ctx.Err()
}
}
}) })
} }