Skip to content

Commit

Permalink
prevent deletion of an active connection while removing outdated conn…
Browse files Browse the repository at this point in the history
…ection with same FD
  • Loading branch information
def committed Mar 14, 2024
1 parent 05c8383 commit 58edfcf
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions containers/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -901,14 +901,19 @@ func (c *Container) gc(now time.Time) {
c.revalidateListens(now, listens)

for srcDst, conn := range c.connectionsActive {
pidFd := PidFd{Pid: conn.Pid, Fd: conn.Fd}
if _, ok := established[srcDst]; !ok {
delete(c.connectionsActive, srcDst)
delete(c.connectionsByPidFd, PidFd{Pid: conn.Pid, Fd: conn.Fd})
if conn == c.connectionsByPidFd[pidFd] {
delete(c.connectionsByPidFd, pidFd)
}
continue
}
if !conn.Closed.IsZero() && now.Sub(conn.Closed) > gcInterval {
delete(c.connectionsActive, srcDst)
delete(c.connectionsByPidFd, PidFd{Pid: conn.Pid, Fd: conn.Fd})
if conn == c.connectionsByPidFd[pidFd] {
delete(c.connectionsByPidFd, pidFd)
}
}
}
for dst, at := range c.connectLastAttempt {
Expand Down

0 comments on commit 58edfcf

Please sign in to comment.