This is an archive of the discontinued LLVM Phabricator instance.

Resurrect pselect MainLoop implementation
ClosedPublic

Authored by labath on Apr 27 2017, 10:59 AM.

Details

Summary

It turns out that even though ppoll is available on all the android
devices we support, it does not seem to be working properly on all of
them -- MainLoop just does a busy loop with ppoll returning EINTR and
not making any progress.

This brings back the pselect implementation and makes it available on
android. I could not do any cmake checks for this as the ppoll symbol is
actually avaiable -- it just does not work.

I haven't tested (or even built) this yet on platforms other than linux,
but I wanted to share this early to get feedback on the way I abstract
the pselect/ppoll/kevent implementations.

Diff Detail

Repository
rL LLVM

Event Timeline

labath created this revision.Apr 27 2017, 10:59 AM
beanz accepted this revision.Apr 27 2017, 11:02 AM

This looks like a nice improvement. There are some formatting inconsistencies, can you run clang-format?

This revision is now accepted and ready to land.Apr 27 2017, 11:02 AM
eugene added inline comments.Apr 27 2017, 3:03 PM
source/Host/common/MainLoop.cpp
82 ↗(On Diff #96946)

here and below struct seems to be redundant

zturner added inline comments.
source/Host/common/MainLoop.cpp
135 ↗(On Diff #96946)

Why do we need this function? Just have a function that returns an ArrayRef<int> and let the caller iterate over it themselves.

143 ↗(On Diff #96946)

Same here.

167 ↗(On Diff #96946)

How about just moving this #ifdef up outside of the Poll function? Given that it occurs so many times, i think it makes the logic and the differences between the two implementations easier to follow.

labath added inline comments.Apr 28 2017, 12:38 AM
source/Host/common/MainLoop.cpp
82 ↗(On Diff #96946)

One of them holds the input events, and the other the output -- I am assuming they can't be the same. @beanz?

I am going to rename them to reflect this better though.

135 ↗(On Diff #96946)

The logic for detecting whether an event has actually happened is different for ppoll and kevent based implementations. In case of kevent you already get a list of events ready, so it may seem that it is redundant, but in case of ppoll, I have to look through the list of input events, and check that they have they POLLIN flag set. This is basically what is this trying to abstract. I can believe it is overkill though.

I'll see if I can come up with something cleaner.

167 ↗(On Diff #96946)

OK.

labath updated this revision to Diff 97074.Apr 28 2017, 3:35 AM

Address review feedback.

I am going to check this in to unbork the android bots. I'm happy to address any additional feedback in a followup.

I'm also planning to come some unit tests for this class next week.

This revision was automatically updated to reflect the committed changes.