Fix closed channel panic

This commit is contained in:
ppom 2023-09-22 23:18:08 +02:00
parent a119e0814b
commit be991e9665

View File

@ -37,6 +37,7 @@ func createDB(path string) *WriteDB {
func DatabaseManager(c *Conf) {
logDB, flushDB := c.RotateDB(true)
close(startupMatchesC)
c.manageLogs(logDB, flushDB)
}
@ -63,7 +64,6 @@ func (c *Conf) manageLogs(logDB *WriteDB, flushDB *WriteDB) {
}
func (c *Conf) RotateDB(startup bool) (*WriteDB, *WriteDB) {
defer close(startupMatchesC)
var (
doesntExist bool
err error
@ -192,7 +192,6 @@ func rotateDB(c *Conf, logDec *gob.Decoder, flushDec *gob.Decoder, logEnc *gob.E
// store matches
if !entry.Exec && entry.T.Add(filter.retryDuration).Unix() > now.Unix() {
if startup {
log.Println("DEBUG db send match")
startupMatchesC <- PFT{entry.Pattern, filter, entry.T}
}
@ -202,7 +201,6 @@ func rotateDB(c *Conf, logDec *gob.Decoder, flushDec *gob.Decoder, logEnc *gob.E
// replay executions
if entry.Exec && entry.T.Add(*filter.longuestActionDuration).Unix() > now.Unix() {
if startup {
log.Println("DEBUG db send match")
cleanMatchesC <- PF{entry.Pattern, filter}
filter.sendActions(entry.Pattern, entry.T)
}