Bladeren bron

prevent deletion of an active connection while removing outdated connection with same FD

Nikolay Sivko 2 jaren geleden
bovenliggende
commit
58edfcfdc6
1 gewijzigde bestanden met toevoegingen van 7 en 2 verwijderingen
  1. 7 2
      containers/container.go

+ 7 - 2
containers/container.go

@@ -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 {