Enable periodic cleaning of mqueue

This commit is contained in:
yo 2022-09-17 11:06:15 +02:00
parent b82615a974
commit ea673b809c

View File

@ -125,7 +125,7 @@ var (
File os.File
Writer *bufio.Writer
Version = "0.6.7"
Version = "0.6.8"
BuildInfo = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "openldaplogparser_build_info",
@ -322,7 +322,7 @@ func writeOut(msg string, filename string) error {
}
// Every 24H, remove connections closed more than 24 hours ago
func periodicallyCleanMQueue(mqueue map[int]*OpenLdapConnection, mqMtx *sync.Mutex) {
func periodicallyCleanMQueue(mqueue map[string]*OpenLdapConnection, mqMtx *sync.Mutex) {
var ok bool
for range time.Tick(time.Hour * 24) {
@ -339,7 +339,8 @@ func periodicallyCleanMQueue(mqueue map[int]*OpenLdapConnection, mqMtx *sync.Mut
}
if ok == true {
mqMtx.Lock()
delete(mqueue, ldcon.ConnId)
//delete(mqueue, ldcon.ConnId)
delete(mqueue, fmt.Sprintf("%s:%d", ldcon.Hostname, ldcon.ConnId))
mqMtx.Unlock()
}
}
@ -970,7 +971,7 @@ func processLogs(cmd *cobra.Command, args []string) {
}
// Cleaner thread
//go periodicallyCleanMQueue(mQueue, &mqMtx)
go periodicallyCleanMQueue(mQueue, &mqMtx)
// Initialize Stdin input...
if true == strings.EqualFold(gSyslogListenAddress, "do-not-listen") {