fix(probe/ebpf): feed initial connections synchronously on restart

If we run `getInitialState()` async there is some chance we will see
another ebpf failure and call `useProcfs()` before `getInitialState()`
gets to the last line, whereupon it will crash on nil pointer.

Also it seems pointless to call `performEbpfTrack()` without waiting
for something to feed in, so I suspect this is what the original
author had in mind.

It will slow down this one `Report()` on machines with a lot of
processes or connections, but ebpfTracker restart is supposed to be a
rare event.
This commit is contained in:
Bryan Boreham
2019-10-14 08:22:21 +00:00
parent 86d83c658d
commit ae83c6545e

View File

@@ -86,7 +86,7 @@ func (t *connectionTracker) ReportConnections(rpt *report.Report) {
log.Warnf("ebpf tracker died, restarting it")
err := t.ebpfTracker.restart()
if err == nil {
go t.getInitialState()
t.getInitialState()
t.performEbpfTrack(rpt, hostNodeID)
return
}