Skip to content

Commit 2c95818

Browse files
authored
Merge pull request #72 from coroot/fix_active_connection_gc
prevent deletion of an active connection while removing outdated connection with same FD
2 parents 05c8383 + 58edfcf commit 2c95818

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

containers/container.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -901,14 +901,19 @@ func (c *Container) gc(now time.Time) {
901901
c.revalidateListens(now, listens)
902902

903903
for srcDst, conn := range c.connectionsActive {
904+
pidFd := PidFd{Pid: conn.Pid, Fd: conn.Fd}
904905
if _, ok := established[srcDst]; !ok {
905906
delete(c.connectionsActive, srcDst)
906-
delete(c.connectionsByPidFd, PidFd{Pid: conn.Pid, Fd: conn.Fd})
907+
if conn == c.connectionsByPidFd[pidFd] {
908+
delete(c.connectionsByPidFd, pidFd)
909+
}
907910
continue
908911
}
909912
if !conn.Closed.IsZero() && now.Sub(conn.Closed) > gcInterval {
910913
delete(c.connectionsActive, srcDst)
911-
delete(c.connectionsByPidFd, PidFd{Pid: conn.Pid, Fd: conn.Fd})
914+
if conn == c.connectionsByPidFd[pidFd] {
915+
delete(c.connectionsByPidFd, pidFd)
916+
}
912917
}
913918
}
914919
for dst, at := range c.connectLastAttempt {

0 commit comments

Comments
 (0)