diff options
author | Christopher Koch <chrisko@google.com> | 2019-02-08 10:50:14 -0800 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-02-08 10:51:24 -0800 |
commit | 5079b38a9af1d66ad720005d7487dd711a0cb713 (patch) | |
tree | 8aa1bcf46e69ac8ab5875acdad16f30422e341a2 /pkg/fd/fd.go | |
parent | 80f901b16b8bb8fe397cc44578035173f5155b24 (diff) |
Keep FilePayloads open on server side until after RPC completed.
Prevents URPC FDs from being closed mid-call, especially if they
are used as raw FDs.
PiperOrigin-RevId: 233087955
Change-Id: I815a2ff32cc5f03774605aef0b35a32862f8e633
Diffstat (limited to 'pkg/fd/fd.go')
-rw-r--r-- | pkg/fd/fd.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/pkg/fd/fd.go b/pkg/fd/fd.go index f6656ffa1..a2edf2aa6 100644 --- a/pkg/fd/fd.go +++ b/pkg/fd/fd.go @@ -158,6 +158,9 @@ func New(fd int) *FD { // The returned FD is always blocking (Go 1.9+). func NewFromFile(file *os.File) (*FD, error) { fd, err := syscall.Dup(int(file.Fd())) + // Technically, the runtime may call the finalizer on file as soon as + // Fd() returns. + runtime.KeepAlive(file) if err != nil { return &FD{ReadWriter{-1}}, err } |