mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
Merge pull request #29968 from ZTE-PaaS/zhangke-patch-014
Automatic merge from submit-queue optimize lock of runtimeState stuct use sync.RWMutex may be high effective for concorrent read
This commit is contained in:
commit
c393f11261
@ -23,7 +23,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type runtimeState struct {
|
type runtimeState struct {
|
||||||
sync.Mutex
|
sync.RWMutex
|
||||||
lastBaseRuntimeSync time.Time
|
lastBaseRuntimeSync time.Time
|
||||||
baseRuntimeSyncThreshold time.Duration
|
baseRuntimeSyncThreshold time.Duration
|
||||||
networkError error
|
networkError error
|
||||||
@ -57,8 +57,8 @@ func (s *runtimeState) setPodCIDR(cidr string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *runtimeState) podCIDR() string {
|
func (s *runtimeState) podCIDR() string {
|
||||||
s.Lock()
|
s.RLock()
|
||||||
defer s.Unlock()
|
defer s.RUnlock()
|
||||||
return s.cidr
|
return s.cidr
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,8 +69,8 @@ func (s *runtimeState) setInitError(err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *runtimeState) errors() []string {
|
func (s *runtimeState) errors() []string {
|
||||||
s.Lock()
|
s.RLock()
|
||||||
defer s.Unlock()
|
defer s.RUnlock()
|
||||||
var ret []string
|
var ret []string
|
||||||
if s.initError != nil {
|
if s.initError != nil {
|
||||||
ret = append(ret, s.initError.Error())
|
ret = append(ret, s.initError.Error())
|
||||||
|
Loading…
Reference in New Issue
Block a user