summaryrefslogtreecommitdiff
path: root/internal/eventloop.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/eventloop.go')
-rw-r--r--internal/eventloop.go41
1 files changed, 39 insertions, 2 deletions
diff --git a/internal/eventloop.go b/internal/eventloop.go
index 2c3cf49..6500508 100644
--- a/internal/eventloop.go
+++ b/internal/eventloop.go
@@ -32,8 +32,11 @@ type eventLoopConfig struct {
countField string
pprofEnable bool
plainMode bool
- fdTracker *fdTracker
- commResolver *commResolver
+ // synchronousRawProcessing keeps raw decode and callback emission in a
+ // single goroutine for deterministic test execution.
+ synchronousRawProcessing bool
+ fdTracker *fdTracker
+ commResolver *commResolver
}
type fdTracker struct {
@@ -385,12 +388,46 @@ func (e *eventLoop) run(ctx context.Context, rawCh <-chan []byte) {
if e.printCb == nil {
e.printCb = func(ep *event.Pair) { ep.Recycle() }
}
+ if e.cfg.synchronousRawProcessing {
+ e.runSynchronously(ctx, rawCh)
+ return
+ }
for ep := range e.events(ctx, rawCh) {
e.printCb(ep)
e.numSyscallsAfterFilter++
}
}
+func (e *eventLoop) runSynchronously(ctx context.Context, rawCh <-chan []byte) {
+ pairs := make(chan *event.Pair, 1)
+
+ for {
+ select {
+ case raw, ok := <-rawCh:
+ if !ok {
+ return
+ }
+ if len(raw) == 0 {
+ continue
+ }
+ e.processRawEvent(raw, pairs)
+ for {
+ select {
+ case ep := <-pairs:
+ e.printCb(ep)
+ e.numSyscallsAfterFilter++
+ default:
+ goto nextRaw
+ }
+ }
+ case <-ctx.Done():
+ fmt.Println("Stopping event loop")
+ return
+ }
+ nextRaw:
+ }
+}
+
func (e *eventLoop) events(ctx context.Context, rawCh <-chan []byte) <-chan *event.Pair {
ch := make(chan *event.Pair)