diff options
author | Tamir Duberstein <tamird@google.com> | 2020-06-24 13:54:58 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-06-24 13:56:38 -0700 |
commit | 10930b0f8c1ff2ac83c7a30cc1f78112a35e3183 (patch) | |
tree | 200c919580a694aa79d1b1fe80982fc100090ffc /pkg/sentry | |
parent | b070e218c6fe61c6ef98e0a3af5ad58d7e627632 (diff) |
Remove waiter.Entry.Context
This field is redundant since state can be stored in the callback.
PiperOrigin-RevId: 318134855
Diffstat (limited to 'pkg/sentry')
-rw-r--r-- | pkg/sentry/kernel/epoll/epoll.go | 13 | ||||
-rw-r--r-- | pkg/sentry/kernel/epoll/epoll_state.go | 3 |
2 files changed, 8 insertions, 8 deletions
diff --git a/pkg/sentry/kernel/epoll/epoll.go b/pkg/sentry/kernel/epoll/epoll.go index 3d78cd48f..679ab495d 100644 --- a/pkg/sentry/kernel/epoll/epoll.go +++ b/pkg/sentry/kernel/epoll/epoll.go @@ -271,11 +271,13 @@ func (e *EventPoll) ReadEvents(max int) []linux.EpollEvent { // readyCallback is called when one of the files we're polling becomes ready. It // moves said file to the readyList if it's currently in the waiting list. -type readyCallback struct{} +type readyCallback struct { + context *pollEntry +} // Callback implements waiter.EntryCallback.Callback. -func (*readyCallback) Callback(w *waiter.Entry) { - entry := w.Context.(*pollEntry) +func (r *readyCallback) Callback(*waiter.Entry) { + entry := r.context e := entry.epoll e.listsMu.Lock() @@ -310,7 +312,7 @@ func (e *EventPoll) initEntryReadiness(entry *pollEntry) { // Check if the file happens to already be in a ready state. ready := f.Readiness(entry.mask) & entry.mask if ready != 0 { - (*readyCallback).Callback(nil, &entry.waiter) + (&readyCallback{context: entry}).Callback(&entry.waiter) } } @@ -380,10 +382,9 @@ func (e *EventPoll) AddEntry(id FileIdentifier, flags EntryFlags, mask waiter.Ev userData: data, epoll: e, flags: flags, - waiter: waiter.Entry{Callback: &readyCallback{}}, mask: mask, } - entry.waiter.Context = entry + entry.waiter.Callback = &readyCallback{context: entry} e.files[id] = entry entry.file = refs.NewWeakRef(id.File, entry) diff --git a/pkg/sentry/kernel/epoll/epoll_state.go b/pkg/sentry/kernel/epoll/epoll_state.go index 8e9f200d0..02f9aabfa 100644 --- a/pkg/sentry/kernel/epoll/epoll_state.go +++ b/pkg/sentry/kernel/epoll/epoll_state.go @@ -21,8 +21,7 @@ import ( // afterLoad is invoked by stateify. func (p *pollEntry) afterLoad() { - p.waiter = waiter.Entry{Callback: &readyCallback{}} - p.waiter.Context = p + p.waiter.Callback = &readyCallback{context: p} p.file = refs.NewWeakRef(p.id.File, p) p.id.File.EventRegister(&p.waiter, p.mask) } |