Skip to content

Commit

Permalink
review updates
Browse files Browse the repository at this point in the history
Signed-off-by: Waldemar Quevedo <wally@nats.io>
  • Loading branch information
wallyqs committed May 13, 2023
1 parent 94b8d0b commit 0c3144a
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions server/accounts.go
Expand Up @@ -3991,7 +3991,6 @@ func (dr *DirAccResolver) Start(s *Server) error {
defer dr.Unlock()
dr.Server = s
dr.operator = opKeys
fetchTimeout := dr.fetchTimeout
dr.DirJWTStore.changed = func(pubKey string) {
if v, ok := s.accounts.Load(pubKey); ok {
if theJwt, err := dr.LoadAcc(pubKey); err != nil {
Expand Down Expand Up @@ -4084,7 +4083,6 @@ func (dr *DirAccResolver) Start(s *Server) error {
s.Debugf("DirResolver - Could not find account %q", accName)
// Reply with empty response to signal absence of JWT to others,
// but not too fast to mitigate beating actual responses with content.
time.Sleep(fetchTimeout / 10)
s.sendInternalMsgLocked(reply, _EMPTY_, nil, nil)
} else {
s.Errorf("DirResolver - Error looking up account %q: %v", accName, err)
Expand Down Expand Up @@ -4250,18 +4248,16 @@ func (s *Server) fetch(res AccountResolver, name string, timeout time.Duration)
replies := s.sys.replies

// Store our handler.
replies[replySubj] = func(sub *subscription, _ *client, _ *Account, subject, reply string, msg []byte) {
replies[replySubj] = func(sub *subscription, _ *client, _ *Account, subject, _ string, msg []byte) {
clone := make([]byte, len(msg))
copy(clone, msg)

s.mu.Lock()
defer s.mu.Unlock()
expectedServers--
if len(msg) == 0 {
// Skip empty responses until getting all the available servers.
if expectedServers > 0 {
s.mu.Unlock()
return
}
// Skip empty responses until getting all the available servers.
if len(msg) == 0 && expectedServers > 0 {
return
}
// Use the first valid response if there is still interest or
// one of the empty responses to signal that it was not found.
Expand All @@ -4271,7 +4267,6 @@ func (s *Server) fetch(res AccountResolver, name string, timeout time.Duration)
default:
}
}
s.mu.Unlock()
}
s.sendInternalMsg(accountLookupRequest, replySubj, nil, []byte{})
quit := s.quitCh
Expand Down

0 comments on commit 0c3144a

Please sign in to comment.