Skip to content

Commit ded396d

Browse files
authored
Add mutex lock to nginxConfigCache in instance watcher service (#1151)
1 parent e050ee9 commit ded396d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

internal/watcher/instance/instance_watcher_service.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,11 @@ func (iw *InstanceWatcherService) checkForUpdates(
218218
"error", parseErr,
219219
)
220220
} else {
221+
iw.cacheMutex.Lock()
221222
iw.sendNginxConfigContextUpdate(newCtx, nginxConfigContext)
222-
iw.nginxConfigCache[nginxConfigContext.InstanceID] = nginxConfigContext
223223
proto.UpdateNginxInstanceRuntime(newInstance, nginxConfigContext)
224-
iw.cacheMutex.Lock()
224+
225+
iw.nginxConfigCache[nginxConfigContext.InstanceID] = nginxConfigContext
225226
iw.instanceCache[newInstance.GetInstanceMeta().GetInstanceId()] = newInstance
226227
iw.cacheMutex.Unlock()
227228
}

0 commit comments

Comments
 (0)