summaryrefslogtreecommitdiffhomepage
path: root/pkg/urpc/urpc.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/urpc/urpc.go')
-rw-r--r--pkg/urpc/urpc.go12
1 files changed, 12 insertions, 0 deletions
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.