Skip to content

Commit 2ff229e

Browse files
committed
⚰️ 简化 getdata
1 parent 18def7c commit 2ff229e

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

control/rule.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -211,20 +211,11 @@ func (m *Control) GetData(gid int64) int64 {
211211
var c grpcfg
212212
var err error
213213
log.Debugln("[control] IsEnabledIn recv gid =", gid)
214-
if gid != 0 {
215-
m.RLock()
216-
err = db.Find(m.service, &c, "WHERE gid = "+strconv.FormatInt(gid, 10))
217-
m.RUnlock()
218-
if err == nil && gid == c.GroupID {
219-
log.Debugf("[control] plugin %s of grp %d : %x", m.service, c.GroupID, c.Disable>>1)
220-
return c.Disable >> 1
221-
}
222-
}
223214
m.RLock()
224-
err = db.Find(m.service, &c, "WHERE gid = 0")
215+
err = db.Find(m.service, &c, "WHERE gid = "+strconv.FormatInt(gid, 10))
225216
m.RUnlock()
226-
if err == nil && c.GroupID == 0 {
227-
log.Debugf("[control] plugin %s of all : %x", m.service, c.Disable>>1)
217+
if err == nil && gid == c.GroupID {
218+
log.Debugf("[control] plugin %s of grp %d : %x", m.service, c.GroupID, c.Disable>>1)
228219
return c.Disable >> 1
229220
}
230221
return 0

0 commit comments

Comments
 (0)