uNetworking / uSockets

Miniscule cross-platform eventing, networking & crypto for async applications
Apache License 2.0
1.29k stars 268 forks source link

when using epoll, I guess any fallthrough-poll should not be closed? #52

Open wuhanck opened 5 years ago

wuhanck commented 5 years ago

I read the eventing/epoll.c. When create fallthrough-poll, it doesn't touch loop->num_polls. When close fallthrough-poll, it will do loop->num_polls--. It is a designed behavior and imply fallthrough-poll may not be closed? or I miss sth?

ghost commented 5 years ago

This seems like a bug in epoll.c

ghost commented 5 years ago

So the point of a fallthrough poll or async is to.. fall through. That is, they are supposed to be left in the loop until the loop falls through. This means that it doesn't matter that much if we go negative or not, because that integer is never read.

It could be made a bit more elegant and more obvious but yeah, this is not an issue in real usage. For instance, the epoll lopp has 1 fallthrough timer and 1 fallthrough async. They are held by the loop itself, and will only be closed after the loop has fallen through.

So it never becomes a problem. All your polls should be non-fallthrough anyways, only things relating to the loop itself should be fallthrough.