From 350ef86dd674c49a7dc8f083b68d99eb05b86a29 Mon Sep 17 00:00:00 2001 From: fumiama Date: Sat, 16 Oct 2021 13:33:12 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20=20control=20=E5=87=8F?= =?UTF-8?q?=E5=B0=91=20defer=20=E5=BC=80=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- control/rule.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/control/rule.go b/control/rule.go index ac040247..c4038a63 100644 --- a/control/rule.go +++ b/control/rule.go @@ -40,8 +40,8 @@ func newctrl(service string, o *Options) *Control { }(), } mu.Lock() - defer mu.Unlock() managers[service] = m + mu.Unlock() err := db.Create(service, &grpcfg{}) if err != nil { panic(err) @@ -101,8 +101,8 @@ func (m *Control) Handler() zero.Rule { // not exist, it will returns nil. func Lookup(service string) (*Control, bool) { mu.RLock() - defer mu.RUnlock() m, ok := managers[service] + mu.RUnlock() return m, ok }