Remove refcounts on destroy and flush
This commit is contained in:
1 parent
3afc528c88
commit
201321f390
1 file changed
+12
@@ -53,18 +53,22 @@ func (i *ipset) DelEntry(ipsetName Name, entry string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i *ipset) Flush(ipsetName Name) error {
|
func (i *ipset) Flush(ipsetName Name) error {
|
||||||
|
i.removeSet(ipsetName)
|
||||||
return doExec("flush", string(ipsetName))
|
return doExec("flush", string(ipsetName))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *ipset) FlushAll() error {
|
func (i *ipset) FlushAll() error {
|
||||||
|
i.refCount = newRefCount()
|
||||||
return doExec("flush")
|
return doExec("flush")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *ipset) Destroy(ipsetName Name) error {
|
func (i *ipset) Destroy(ipsetName Name) error {
|
||||||
|
i.removeSet(ipsetName)
|
||||||
return doExec("destroy", string(ipsetName))
|
return doExec("destroy", string(ipsetName))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *ipset) DestroyAll() error {
|
func (i *ipset) DestroyAll() error {
|
||||||
|
i.refCount = newRefCount()
|
||||||
return doExec("destroy")
|
return doExec("destroy")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,3 +105,11 @@ func (rc *refCount) dec(ipsetName Name, entry string) int {
|
|||||||
rc.ref[k]--
|
rc.ref[k]--
|
||||||
return rc.ref[k]
|
return rc.ref[k]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (rc *refCount) removeSet(ipsetName Name) {
|
||||||
|
for k := range rc.ref {
|
||||||
|
if k.ipsetName == ipsetName {
|
||||||
|
delete(rc.ref, k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user