mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-15 18:50:41 -07:00
Reduce usage of tmpAccounts to only location where it is needed imports
On import handle it with priority as in non recursive situations, it won't be present.
This commit is contained in:
@@ -2353,7 +2353,14 @@ func (s *Server) UpdateAccountClaims(a *Account, ac *jwt.AccountClaims) {
|
||||
}
|
||||
}
|
||||
for _, i := range ac.Imports {
|
||||
acc, err := s.lookupAccount(i.Account)
|
||||
// check tmpAccounts with priority
|
||||
acc := (*Account)(nil)
|
||||
err := error(nil)
|
||||
if v, ok := s.tmpAccounts.Load(i.Account); ok {
|
||||
acc = v.(*Account)
|
||||
} else {
|
||||
acc, err = s.lookupAccount(i.Account)
|
||||
}
|
||||
if acc == nil || err != nil {
|
||||
s.Errorf("Can't locate account [%s] for import of [%v] %s (err=%v)", i.Account, i.Subject, i.Type, err)
|
||||
continue
|
||||
|
||||
@@ -1011,8 +1011,6 @@ func (c *client) processRemoteSub(argo []byte, hasOrigin bool) (err error) {
|
||||
acc, _ = srv.LookupAccount(accountName)
|
||||
} else if v, ok := srv.accounts.Load(accountName); ok {
|
||||
acc = v.(*Account)
|
||||
} else if v, ok := srv.tmpAccounts.Load(accountName); ok {
|
||||
acc = v.(*Account)
|
||||
}
|
||||
if acc == nil {
|
||||
expire := false
|
||||
|
||||
@@ -1124,8 +1124,6 @@ func (s *Server) lookupAccount(name string) (*Account, error) {
|
||||
var acc *Account
|
||||
if v, ok := s.accounts.Load(name); ok {
|
||||
acc = v.(*Account)
|
||||
} else if v, ok := s.tmpAccounts.Load(name); ok {
|
||||
acc = v.(*Account)
|
||||
}
|
||||
if acc != nil {
|
||||
// If we are expired and we have a resolver, then
|
||||
|
||||
Reference in New Issue
Block a user