From be991e966559120bacfc34ad614daf96d8ee6d16 Mon Sep 17 00:00:00 2001 From: ppom <> Date: Fri, 22 Sep 2023 23:18:08 +0200 Subject: [PATCH] Fix closed channel panic --- app/persist.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/persist.go b/app/persist.go index 4f5ed69..d273ad1 100644 --- a/app/persist.go +++ b/app/persist.go @@ -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) }