Skip to content

Commit

Permalink
backend: fix the bug that the redirection signal may be discarded (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
djshow832 authored Sep 5, 2022
1 parent 8d8a09e commit ddf7bfb
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pkg/proxy/backend/backend_conn_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func NewBackendConnManager(connectionID uint64) *BackendConnManager {
connectionID: connectionID,
cmdProcessor: NewCmdProcessor(),
authenticator: &Authenticator{},
signalReceived: make(chan struct{}),
signalReceived: make(chan struct{}, 1),
redirectResCh: make(chan *redirectResult, 1),
}
}
Expand Down Expand Up @@ -292,10 +292,8 @@ func (mgr *BackendConnManager) Redirect(newAddr string) {
atomic.StorePointer(&mgr.signal, unsafe.Pointer(&signalRedirect{
newAddr: newAddr,
}))
select {
case mgr.signalReceived <- struct{}{}:
default:
}
// Generally, it won't wait because the caller won't send another signal because the last one finishes.
mgr.signalReceived <- struct{}{}
}

// GetRedirectingAddr implements RedirectableConn.GetRedirectingAddr interface.
Expand Down

0 comments on commit ddf7bfb

Please sign in to comment.