3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-10 22:19:31 +01:00

fix a memory leak

Even after the timer fired, we were retaining a pointer to it;
clean those up too along with the other cleanup tasks.
This commit is contained in:
Shivaram Lingamneni 2019-01-23 01:55:44 -05:00
parent 854d85a474
commit 96737ea6d7
2 changed files with 2 additions and 0 deletions

View File

@ -158,6 +158,7 @@ func (dm *DLineManager) addNetworkInternal(network net.IPNet, info IPBanInfo) (i
if ok && netBan.Info.TimeCreated.Equal(timeCreated) {
delete(dm.networks, id)
// TODO(slingamn) here's where we'd remove it from the radix tree
delete(dm.expirationTimers, id)
}
}
dm.expirationTimers[id] = time.AfterFunc(timeLeft, processExpiration)

View File

@ -113,6 +113,7 @@ func (km *KLineManager) addMaskInternal(mask string, info IPBanInfo) {
maskBan, ok := km.entries[mask]
if ok && maskBan.Info.TimeCreated.Equal(timeCreated) {
delete(km.entries, mask)
delete(km.expirationTimers, mask)
}
}
km.expirationTimers[mask] = time.AfterFunc(timeLeft, processExpiration)