Skip to content

Commit 0905327

Browse files
fix(analyze): split input channel
Avoid deadlocks by writing first into a from file channel buffer, then into the engine.
1 parent 3294178 commit 0905327

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg/analyze/analyze.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ func Analyze(cfg Config) {
6464

6565
engineOutput := make(chan *detect.Finding)
6666
engineInput := make(chan protocol.Event)
67+
fromFile := make(chan protocol.Event)
6768

6869
source := engine.EventSources{Tracee: engineInput}
6970
sigEngine, err := engine.NewEngine(engineConfig, source, engineOutput)
@@ -87,7 +88,7 @@ func Analyze(cfg Config) {
8788
}
8889

8990
// producer
90-
go produce(fileReadCtx, stop, cfg.Source, engineInput)
91+
go produce(fileReadCtx, stop, cfg.Source, fromFile)
9192

9293
cfg.Printer.Preamble()
9394
defer cfg.Printer.Close()
@@ -112,6 +113,11 @@ drain:
112113
defer close(engineInput)
113114
for {
114115
select {
116+
case event, ok := <-fromFile:
117+
if !ok {
118+
return
119+
}
120+
engineInput <- event
115121
case finding, ok := <-engineOutput:
116122
if !ok {
117123
return

0 commit comments

Comments
 (0)