Skip to content

Commit 638d0c4

Browse files
committed
try to avoid exec events were handled after packet events
1 parent ee93014 commit 638d0c4

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

internal/consumer/exec.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ package consumer
22

33
import (
44
"context"
5+
"log"
6+
"sync"
7+
58
"github.com/mozillazg/ptcpdump/bpf"
69
"github.com/mozillazg/ptcpdump/internal/event"
710
"github.com/mozillazg/ptcpdump/internal/metadata"
8-
"log"
911
)
1012

1113
type ExecEventConsumer struct {
@@ -19,6 +21,18 @@ func NewExecEventConsumer(pcache *metadata.ProcessCache) *ExecEventConsumer {
1921
}
2022

2123
func (c *ExecEventConsumer) Start(ctx context.Context, ch <-chan bpf.BpfExecEventT) {
24+
wg := sync.WaitGroup{}
25+
for i := 0; i < 5; i++ {
26+
wg.Add(1)
27+
go func() {
28+
defer wg.Done()
29+
c.worker(ctx, ch)
30+
}()
31+
}
32+
wg.Wait()
33+
}
34+
35+
func (c *ExecEventConsumer) worker(ctx context.Context, ch <-chan bpf.BpfExecEventT) {
2236
for {
2337
select {
2438
case <-ctx.Done():

0 commit comments

Comments
 (0)