mirror of
https://github.com/netbirdio/netbird.git
synced 2026-03-31 06:34:19 -04:00
[management] create a shallow copy of the account when buffering (#5572)
This commit is contained in:
@@ -86,7 +86,14 @@ func (ac *AccountRequestBuffer) processGetAccountBatch(ctx context.Context, acco
|
|||||||
result := &AccountResult{Account: account, Err: err}
|
result := &AccountResult{Account: account, Err: err}
|
||||||
|
|
||||||
for _, req := range requests {
|
for _, req := range requests {
|
||||||
req.ResultChan <- result
|
if account != nil {
|
||||||
|
// Shallow copy the account so each goroutine gets its own struct value.
|
||||||
|
// This prevents data races when callers mutate fields like Policies.
|
||||||
|
accountCopy := *account
|
||||||
|
req.ResultChan <- &AccountResult{Account: &accountCopy, Err: err}
|
||||||
|
} else {
|
||||||
|
req.ResultChan <- result
|
||||||
|
}
|
||||||
close(req.ResultChan)
|
close(req.ResultChan)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user