diff options
Diffstat (limited to 'pkg/urpc')
-rw-r--r-- | pkg/urpc/BUILD | 1 | ||||
-rw-r--r-- | pkg/urpc/urpc.go | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/pkg/urpc/BUILD b/pkg/urpc/BUILD index 36cae67e1..0192fb35b 100644 --- a/pkg/urpc/BUILD +++ b/pkg/urpc/BUILD @@ -8,6 +8,7 @@ go_library( importpath = "gvisor.googlesource.com/gvisor/pkg/urpc", visibility = ["//:sandbox"], deps = [ + "//pkg/fd", "//pkg/log", "//pkg/unet", ], diff --git a/pkg/urpc/urpc.go b/pkg/urpc/urpc.go index 753366be2..6d528b180 100644 --- a/pkg/urpc/urpc.go +++ b/pkg/urpc/urpc.go @@ -29,6 +29,7 @@ import ( "runtime" "sync" + "gvisor.googlesource.com/gvisor/pkg/fd" "gvisor.googlesource.com/gvisor/pkg/log" "gvisor.googlesource.com/gvisor/pkg/unet" ) @@ -71,6 +72,11 @@ type FilePayload struct { Files []*os.File `json:"-"` } +// ReleaseFD releases the indexth FD. +func (f *FilePayload) ReleaseFD(index int) (*fd.FD, error) { + return fd.NewFromFile(f.Files[index]) +} + // filePayload returns the file. It may be nil. func (f *FilePayload) filePayload() []*os.File { return f.Files @@ -268,6 +274,12 @@ func (s *Server) handleOne(client *unet.Socket) error { return err } + // Explicitly close all these files after the call. + // + // This is also explicitly a reference to the files after the call, + // which means they are kept open for the duration of the call. + defer closeAll(newFs) + // Start the request. if !s.clientBeginRequest(client) { // Client is dead; don't process this call. |