mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Cleanup locking in configz
- Reduce scope of lock in write() method - User read lock in write() method
This commit is contained in:
parent
c1da492ad2
commit
7e7a811717
@ -75,9 +75,13 @@ func handle(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func write(w io.Writer) error {
|
||||
configsGuard.Lock()
|
||||
defer configsGuard.Unlock()
|
||||
b, err := json.Marshal(configs)
|
||||
var b []byte
|
||||
var err error
|
||||
func() {
|
||||
configsGuard.RLock()
|
||||
defer configsGuard.RUnlock()
|
||||
b, err = json.Marshal(configs)
|
||||
}()
|
||||
if err != nil {
|
||||
return fmt.Errorf("error marshaling json: %v", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user