mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 10:11:03 +00:00
eliminate race in ebpf initialization
We were enabling event processing before feeding in the initial connections, which results in a non-deterministic outcome.
This commit is contained in:
@@ -246,15 +246,19 @@ func (t *EbpfTracker) walkConnections(f func(ebpfConnection)) {
|
||||
}
|
||||
|
||||
func (t *EbpfTracker) feedInitialConnections(conns procspy.ConnIter, seenTuples map[string]fourTuple, processesWaitingInAccept []int, hostNodeID string) {
|
||||
t.readyToHandleConnections = true
|
||||
t.Lock()
|
||||
for conn := conns.Next(); conn != nil; conn = conns.Next() {
|
||||
tuple, namespaceID, incoming := connectionTuple(conn, seenTuples)
|
||||
if incoming {
|
||||
t.handleConnection(tracer.EventAccept, tuple, int(conn.Proc.PID), namespaceID)
|
||||
} else {
|
||||
t.handleConnection(tracer.EventConnect, tuple, int(conn.Proc.PID), namespaceID)
|
||||
t.openConnections[tuple] = ebpfConnection{
|
||||
incoming: incoming,
|
||||
tuple: tuple,
|
||||
pid: int(conn.Proc.PID),
|
||||
networkNamespace: namespaceID,
|
||||
}
|
||||
}
|
||||
t.readyToHandleConnections = true
|
||||
t.Unlock()
|
||||
|
||||
for _, p := range processesWaitingInAccept {
|
||||
t.tracer.AddFdInstallWatcher(uint32(p))
|
||||
log.Debugf("EbpfTracker: install fd-install watcher: pid=%d", p)
|
||||
|
||||
Reference in New Issue
Block a user