mirror of
https://github.com/niusmallnan/steve.git
synced 2025-07-12 05:48:02 +00:00
Fix possible panic on race condition
This commit is contained in:
parent
97ff535abc
commit
c6547ae887
@ -175,11 +175,6 @@ func (s *Store) List(apiOp *types.APIRequest, schema *types.APISchema) (types.AP
|
||||
|
||||
func (s *Store) Watch(apiOp *types.APIRequest, schema *types.APISchema, w types.WatchRequest) (chan types.APIEvent, error) {
|
||||
result := make(chan types.APIEvent, 1)
|
||||
go func() {
|
||||
<-apiOp.Context().Done()
|
||||
close(result)
|
||||
}()
|
||||
|
||||
result <- types.APIEvent{
|
||||
Name: "local",
|
||||
ResourceType: "management.cattle.io.clusters",
|
||||
@ -187,5 +182,10 @@ func (s *Store) Watch(apiOp *types.APIRequest, schema *types.APISchema, w types.
|
||||
Object: s.getLocal(),
|
||||
}
|
||||
|
||||
go func() {
|
||||
<-apiOp.Context().Done()
|
||||
close(result)
|
||||
}()
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user