Skip to content

Commit fdfff08

Browse files
committed
CR suggestion
Signed-off-by: Uri Sternik <uri.sternik@wiz.io>
1 parent 1a931be commit fdfff08

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

cmd/config-manager/main.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ type SyncableConfig struct {
8282
cond *sync.Cond
8383
mutex sync.Mutex
8484
current string
85-
lastRead string
86-
initialized bool
85+
lastRead *string
8786
}
8887

8988
// NewSyncableConfig creates a new SyncableConfig
@@ -107,12 +106,12 @@ func (m *SyncableConfig) Set(value string) {
107106
func (m *SyncableConfig) Get() string {
108107
m.mutex.Lock()
109108
defer m.mutex.Unlock()
110-
if m.initialized && m.lastRead == m.current {
109+
if m.lastRead != nil && *m.lastRead == m.current {
111110
m.cond.Wait()
112111
}
113-
m.initialized = true
114-
m.lastRead = m.current
115-
return m.lastRead
112+
val := m.current
113+
m.lastRead = &val
114+
return *m.lastRead
116115
}
117116

118117
func main() {

0 commit comments

Comments
 (0)