Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/ref/runtime/internal/rpc: fix proxymgr shutdown race #410

Merged
merged 6 commits into from
Jan 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions x/ref/runtime/internal/rpc/proxymgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ func drainNotifyChan(ch chan struct{}) {
}
}

func (pm *proxyManager) watchForChanges(ctx *context.T, ch chan struct{}) {
func (pm *proxyManager) watchForChanges(ctx *context.T, ch, doneCh chan struct{}) {
defer close(doneCh)
for {
select {
case <-ctx.Done():
Expand All @@ -260,12 +261,17 @@ func (pm *proxyManager) watchForChanges(ctx *context.T, ch chan struct{}) {

func (pm *proxyManager) manageProxyConnections(ctx *context.T) {
notifyCh := make(chan struct{}, 10)
doneCh := make(chan struct{})

defer func() {
<-doneCh
}()
pm.updateAvailableProxies(ctx)
// Watch for changes in the set of available proxies so that for the
// 'all' policy, the server will connect to new proxies as they appear.
// For other policies reconnection may be little faster since the
// new set of proxies is already available.
go pm.watchForChanges(ctx, notifyCh)
go pm.watchForChanges(ctx, notifyCh, doneCh)

for {
select {
Expand Down