mirror of
https://github.com/niusmallnan/steve.git
synced 2025-07-13 06:14:06 +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) {
|
func (s *Store) Watch(apiOp *types.APIRequest, schema *types.APISchema, w types.WatchRequest) (chan types.APIEvent, error) {
|
||||||
result := make(chan types.APIEvent, 1)
|
result := make(chan types.APIEvent, 1)
|
||||||
go func() {
|
|
||||||
<-apiOp.Context().Done()
|
|
||||||
close(result)
|
|
||||||
}()
|
|
||||||
|
|
||||||
result <- types.APIEvent{
|
result <- types.APIEvent{
|
||||||
Name: "local",
|
Name: "local",
|
||||||
ResourceType: "management.cattle.io.clusters",
|
ResourceType: "management.cattle.io.clusters",
|
||||||
@ -187,5 +182,10 @@ func (s *Store) Watch(apiOp *types.APIRequest, schema *types.APISchema, w types.
|
|||||||
Object: s.getLocal(),
|
Object: s.getLocal(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
<-apiOp.Context().Done()
|
||||||
|
close(result)
|
||||||
|
}()
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user