Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a counter for etw loops and slowed down retry rate. #3207

Merged
merged 3 commits into from
Jan 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions vql/windows/etw/watch_etw.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ type WatchETWArgs struct {
EnableMapInfo bool `vfilter:"optional,field=enable_map_info,doc=Resolving MapInfo with TdhGetEventMapInformation is very expensive and causes events to be dropped so we disabled it by default. Enable with this flag."`
}

type WatchETWPlugin struct{}
type WatchETWPlugin struct {
RetryTimer time.Duration
}

func (self WatchETWPlugin) Call(
ctx context.Context,
Expand Down Expand Up @@ -78,12 +80,14 @@ func (self WatchETWPlugin) Call(
EnableMapInfo: arg.EnableMapInfo,
}

self.RetryTimer = 1 * time.Second
for {
err = self.WatchOnce(ctx, scope, arg.Stop, output_chan,
bmcder02 marked this conversation as resolved.
Show resolved Hide resolved
arg.Name, options, wGuid)
if err != nil {
scope.Log("watch_etw: ETW session interrupted, will retry again.")
utils.SleepWithCtx(ctx, 10*time.Second)
scope.Log("watch_etw: ETW session interrupted, will retry again in %d seconds: %v", self.RetryTimer, err)
utils.SleepWithCtx(ctx, self.RetryTimer)
self.RetryTimer *= 2
continue
scudette marked this conversation as resolved.
Show resolved Hide resolved
}
return
Expand Down Expand Up @@ -127,6 +131,11 @@ func (self WatchETWPlugin) WatchOnce(
return nil
case output_chan <- event:
}

// Slowly reset the time on each successful message.
if self.RetryTimer > 1*time.Second {
self.RetryTimer /= 2
}
}
}

Expand Down