gvisor/pkg/sentry/socket/hostinet
Christopher Koch d154c6a25f Refcount socket Dirents correctly.
This should fix the socket Dirent memory leak.

fs.NewFile takes a new reference. It should hold the *only* reference.
DecRef that socket Dirent.

Before the globalDirentMap was introduced, a mis-refcounted Dirent
would be garbage collected when all references to it were gone. For
socket Dirents, this meant that they would be garbage collected when
the associated fs.Files disappeared.

After the globalDirentMap, Dirents *must* be reference-counted
correctly to be garbage collected, as Dirents remove themselves
from the global map when their refcount goes to -1 (see Dirent.destroy).
That removes the last pointer to that Dirent.

PiperOrigin-RevId: 196878973
Change-Id: Ic7afcd1de97c7101ccb13be5fc31de0fb50963f0
2018-05-16 13:29:17 -07:00
..
BUILD Check in gVisor. 2018-04-28 01:44:26 -04:00
device.go Check in gVisor. 2018-04-28 01:44:26 -04:00
hostinet.go Check in gVisor. 2018-04-28 01:44:26 -04:00
save_restore.go Check in gVisor. 2018-04-28 01:44:26 -04:00
socket.go Refcount socket Dirents correctly. 2018-05-16 13:29:17 -07:00
socket_unsafe.go Check in gVisor. 2018-04-28 01:44:26 -04:00
stack.go Check in gVisor. 2018-04-28 01:44:26 -04:00