From 4d6d98c9d46ad4982ae773bd4613812e2781f836 Mon Sep 17 00:00:00 2001 From: /gray Date: Mon, 29 Jan 2024 18:56:11 +0800 Subject: [PATCH] fix: Create DaeNetns instance strictly once on reload (#446) --- 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 {