From de5b55da434b5568c2074a8ca67cc604b00d6bea Mon Sep 17 00:00:00 2001 From: "Stanislav N. aka pztrn" Date: Sun, 29 Nov 2020 19:36:04 +0500 Subject: [PATCH] Fix fetcher flag usage misplacement. --- internal/application/fetcher.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/application/fetcher.go b/internal/application/fetcher.go index 36cef5b..2f8efcd 100644 --- a/internal/application/fetcher.go +++ b/internal/application/fetcher.go @@ -19,6 +19,10 @@ func (a *Application) fetch() { return } + a.fetchIsRunningMutex.Lock() + a.fetchIsRunning = true + a.fetchIsRunningMutex.Unlock() + log.Println("Fetching data for", a.name) req, err := http.NewRequestWithContext(a.ctx, "GET", a.config.Endpoint, nil) @@ -52,10 +56,6 @@ func (a *Application) fetch() { a.storage.Put(data) - a.fetchIsRunningMutex.Lock() - a.fetchIsRunning = true - a.fetchIsRunningMutex.Unlock() - a.fetchIsRunningMutex.Lock() a.fetchIsRunning = false a.fetchIsRunningMutex.Unlock()