diff options
author | gVisor bot <gvisor-bot@google.com> | 2019-10-16 22:20:51 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2019-10-16 22:20:51 +0000 |
commit | a02f8d0dbefc8a56940a579f07ac1c35be92a112 (patch) | |
tree | 8e44280b5dfecea49eca930c60bfeb4cbfe03e77 /pkg/sentry/fs/gofer/handles.go | |
parent | d8af87b44fcae3f7666005fa0e54d242c3708699 (diff) | |
parent | 9fb562234e7858dbc60e8771f851629464edf205 (diff) |
Merge release-20190806.1-281-g9fb5622 (automated)
Diffstat (limited to 'pkg/sentry/fs/gofer/handles.go')
-rw-r--r-- | pkg/sentry/fs/gofer/handles.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/pkg/sentry/fs/gofer/handles.go b/pkg/sentry/fs/gofer/handles.go index 27eeae3d9..39c8ec33d 100644 --- a/pkg/sentry/fs/gofer/handles.go +++ b/pkg/sentry/fs/gofer/handles.go @@ -39,14 +39,22 @@ type handles struct { // Host is an *fd.FD handle. May be nil. Host *fd.FD + + // isHostBorrowed tells whether 'Host' is owned or borrowed. If owned, it's + // closed on destruction, otherwise it's released. + isHostBorrowed bool } // DecRef drops a reference on handles. func (h *handles) DecRef() { h.DecRefWithDestructor(func() { if h.Host != nil { - if err := h.Host.Close(); err != nil { - log.Warningf("error closing host file: %v", err) + if h.isHostBorrowed { + h.Host.Release() + } else { + if err := h.Host.Close(); err != nil { + log.Warningf("error closing host file: %v", err) + } } } // FIXME(b/38173783): Context is not plumbed here. |