aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/envoyproxy/go-control-plane/pkg/server/delta/v3/watches.go
diff options
context:
space:
mode:
authorAlexander Smirnov <alex@ydb.tech>2024-01-31 17:22:33 +0300
committerAlexander Smirnov <alex@ydb.tech>2024-01-31 17:22:33 +0300
commit52be5dbdd420165c68e7e90ba8f1d2f00da041f6 (patch)
tree5d47f5b2ff4e6a7c8e75d33931a1e683949b7229 /vendor/github.com/envoyproxy/go-control-plane/pkg/server/delta/v3/watches.go
parentea57c8867ceca391357c3c5ffcc5ba6738b49adc (diff)
parent809f0cf2fdfddfbeacc2256ffdbaaf5808ce5ed4 (diff)
downloadydb-52be5dbdd420165c68e7e90ba8f1d2f00da041f6.tar.gz
Merge branch 'mergelibs12' into main
Diffstat (limited to 'vendor/github.com/envoyproxy/go-control-plane/pkg/server/delta/v3/watches.go')
-rw-r--r--vendor/github.com/envoyproxy/go-control-plane/pkg/server/delta/v3/watches.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/vendor/github.com/envoyproxy/go-control-plane/pkg/server/delta/v3/watches.go b/vendor/github.com/envoyproxy/go-control-plane/pkg/server/delta/v3/watches.go
index c88548388a..63c4c2d38d 100644
--- a/vendor/github.com/envoyproxy/go-control-plane/pkg/server/delta/v3/watches.go
+++ b/vendor/github.com/envoyproxy/go-control-plane/pkg/server/delta/v3/watches.go
@@ -17,9 +17,13 @@ type watches struct {
// newWatches creates and initializes watches.
func newWatches() watches {
// deltaMuxedResponses needs a buffer to release go-routines populating it
+ //
+ // because deltaMuxedResponses can be populated by an update from the cache
+ // and a request from the client, we need to create the channel with a buffer
+ // size of 2x the number of types to avoid deadlocks.
return watches{
deltaWatches: make(map[string]watch, int(types.UnknownType)),
- deltaMuxedResponses: make(chan cache.DeltaResponse, int(types.UnknownType)),
+ deltaMuxedResponses: make(chan cache.DeltaResponse, int(types.UnknownType)*2),
}
}
@@ -28,13 +32,14 @@ func (w *watches) Cancel() {
for _, watch := range w.deltaWatches {
watch.Cancel()
}
+
+ close(w.deltaMuxedResponses)
}
// watch contains the necessary modifiables for receiving resource responses
type watch struct {
- responses chan cache.DeltaResponse
- cancel func()
- nonce string
+ cancel func()
+ nonce string
state stream.StreamState
}
@@ -44,9 +49,4 @@ func (w *watch) Cancel() {
if w.cancel != nil {
w.cancel()
}
- if w.responses != nil {
- // w.responses should never be used by a producer once cancel() has been closed, so we can safely close it here
- // This is needed to release resources taken by goroutines watching this channel
- close(w.responses)
- }
}