From ac20ebf1b7bcc999d3935bbc859afe6b68ec6d68 Mon Sep 17 00:00:00 2001 From: Gray Liang Date: Sat, 27 Jan 2024 13:42:01 +0800 Subject: [PATCH] Create DaeNetns instance strictly once on reload --- control/netns_utils.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/control/netns_utils.go b/control/netns_utils.go index 1dee26a6c..3954f94fe 100644 --- a/control/netns_utils.go +++ b/control/netns_utils.go @@ -24,6 +24,7 @@ const ( var ( daeNetns *DaeNetns + once sync.Once ) type DaeNetns struct { @@ -37,9 +38,10 @@ type DaeNetns struct { } func InitDaeNetns(log *logrus.Logger) { - daeNetns = &DaeNetns{ - log: log, - } + once.Do(func() { + daeNetns = &DaeNetns{} + }) + daeNetns.log = log } func GetDaeNetns() *DaeNetns {