From f422ef212a95a4579e69637967735be3bcf7dab5 Mon Sep 17 00:00:00 2001 From: Deepak Ghuge Date: Thu, 13 Dec 2018 13:58:19 +0530 Subject: [PATCH] UB-1761 - Changed order of defer function to avoid iterating and updating map at same time. (#282) Fixing error concurrent map iteration and map write error --- utils/locker.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/locker.go b/utils/locker.go index 25638331..02113db0 100644 --- a/utils/locker.go +++ b/utils/locker.go @@ -104,8 +104,8 @@ func (l *locker) updateStats(name string) { defer l.logger.Trace(logs.DEBUG, logs.Args{{"lockName", name}})() l.statsLock.Lock() - defer l.cleanup() defer l.statsLock.Unlock() + defer l.cleanup() if stat, exists := l.stats[name]; exists { stat = time.Now() l.stats[name] = stat