Skip to content

Commit 842107c

Browse files
authored
fix timemachine lock (#3767)
* refactor without label * fix the deadlock
1 parent 76ea87c commit 842107c

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

cmd/crowdsec/output.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ func runOutput(input chan types.Event, overflow chan types.Event, buckets *leaky
7070
)
7171

7272
ticker := time.NewTicker(1 * time.Second)
73-
LOOP:
73+
defer ticker.Stop()
74+
7475
for {
7576
select {
7677
case <-ticker.C:
@@ -97,8 +98,7 @@ LOOP:
9798
log.Errorf("while pushing leftovers to api : %s", err)
9899
}
99100
}
100-
101-
break LOOP
101+
return nil
102102
case event := <-overflow:
103103
/*if alert is empty and mapKey is present, the overflow is just to cleanup bucket*/
104104
if event.Overflow.Alert == nil && event.Overflow.Mapkey != "" {
@@ -125,7 +125,12 @@ LOOP:
125125
}
126126
if event.Overflow.Reprocess {
127127
log.Debugf("Overflow being reprocessed.")
128-
input <- event
128+
select {
129+
case input <- event:
130+
log.Debugf("reprocessing overflow event")
131+
case <-parsersTomb.Dead():
132+
log.Debugf("parsing is dead, skipping")
133+
}
129134
}
130135
if dumpStates {
131136
continue
@@ -136,8 +141,4 @@ LOOP:
136141
cacheMutex.Unlock()
137142
}
138143
}
139-
140-
ticker.Stop()
141-
142-
return nil
143144
}

0 commit comments

Comments
 (0)