mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Fix memory leak in danglingEndpoints.
Endpoints which were being terminated in an ERROR state or were moved to CLOSED by the worker goroutine do not run cleanupLocked() as that should already be run by the worker termination. But when making that change we made the mistake of not removing the endpoint from the danglingEndpoints which is normally done in cleanupLocked(). As a result these endpoints are leaked since a reference is held to them in the danglingEndpoints array forever till Stack is torn down. PiperOrigin-RevId: 300438426
This commit is contained in:
committed by
gVisor bot
parent
fd84cddab0
commit
81675b850e
@@ -1639,6 +1639,7 @@ func (e *endpoint) doTimeWait() (twReuse func()) {
|
||||
const timeWaitDone = 3
|
||||
|
||||
s := sleep.Sleeper{}
|
||||
defer s.Done()
|
||||
s.AddWaker(&e.newSegmentWaker, newSegment)
|
||||
s.AddWaker(&e.notificationWaker, notification)
|
||||
|
||||
|
||||
@@ -862,7 +862,6 @@ func (e *endpoint) closeNoShutdown() {
|
||||
e.closed = true
|
||||
// Either perform the local cleanup or kick the worker to make sure it
|
||||
// knows it needs to cleanup.
|
||||
tcpip.AddDanglingEndpoint(e)
|
||||
switch e.EndpointState() {
|
||||
// Sockets in StateSynRecv state(passive connections) are closed when
|
||||
// the handshake fails or if the listening socket is closed while
|
||||
@@ -876,6 +875,9 @@ func (e *endpoint) closeNoShutdown() {
|
||||
// do nothing.
|
||||
default:
|
||||
e.workerCleanup = true
|
||||
tcpip.AddDanglingEndpoint(e)
|
||||
// Worker will remove the dangling endpoint when the endpoint
|
||||
// goroutine terminates.
|
||||
e.notifyProtocolGoroutine(notifyClose)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user