From 3ee362a5fe5b0a38e81aba938a081d6d773b7430 Mon Sep 17 00:00:00 2001 From: Ingo Oppermann Date: Tue, 2 May 2023 10:59:57 +0200 Subject: [PATCH] Fix race condition --- restream/resources/resources.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/restream/resources/resources.go b/restream/resources/resources.go index 9a4e9ffc..757b281e 100644 --- a/restream/resources/resources.go +++ b/restream/resources/resources.go @@ -79,6 +79,9 @@ func New(config Config) (Resources, error) { r.maxCPU *= r.ncpu r.maxMemory = uint64(float64(vmstat.Total) * config.MaxMemory / 100) + r.limitCPUCh = make(chan bool, 10) + r.limitMemoryCh = make(chan bool, 10) + r.logger = r.logger.WithFields(log.Fields{ "ncpu": r.ncpu, "max_cpu": r.maxCPU, @@ -94,9 +97,6 @@ func New(config Config) (Resources, error) { func (r *resources) Start() { r.startOnce.Do(func() { - r.limitCPUCh = make(chan bool, 10) - r.limitMemoryCh = make(chan bool, 10) - ctx, cancel := context.WithCancel(context.Background()) r.cancelObserver = cancel