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 {
opts := parse.QueryOptions(apiContext, schema)
events, err := schema.Store.Watch(apiContext, schema, &opts)
if err != nil {
if err != nil || events == nil {
return err
}
if events == nil {
return nil
for e := range events {
result <- e
}
for {
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()
}
}
return nil
})
}