From 23fe059761a470d7724b462ad8ead09356ec21b7 Mon Sep 17 00:00:00 2001 From: Fabricio Voznika Date: Tue, 26 Feb 2019 09:32:20 -0800 Subject: Lazily allocate inotify map on inode PiperOrigin-RevId: 235735865 Change-Id: I84223eb18eb51da1fa9768feaae80387ff6bfed0 --- pkg/sentry/fs/inode_inotify.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'pkg') diff --git a/pkg/sentry/fs/inode_inotify.go b/pkg/sentry/fs/inode_inotify.go index e213df924..d2b653bc7 100644 --- a/pkg/sentry/fs/inode_inotify.go +++ b/pkg/sentry/fs/inode_inotify.go @@ -39,9 +39,7 @@ type Watches struct { } func newWatches() *Watches { - return &Watches{ - ws: make(map[uint64]*Watch), - } + return &Watches{} } // MarkUnlinked indicates the target for this set of watches to be unlinked. @@ -78,6 +76,9 @@ func (w *Watches) Add(watch *Watch) { if _, exists := w.ws[watch.ID()]; exists { panic(fmt.Sprintf("Watch collision with ID %+v", watch.ID())) } + if w.ws == nil { + w.ws = make(map[uint64]*Watch) + } w.ws[watch.ID()] = watch } -- cgit v1.2.3