Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support numbers returned from :events() #5

Closed
daurnimator opened this issue Oct 13, 2014 · 7 comments
Closed

Support numbers returned from :events() #5

daurnimator opened this issue Oct 13, 2014 · 7 comments

Comments

@daurnimator
Copy link
Collaborator

I often already have a bitmask ready for poll() from a 3rd party C lib.

Could you make it so the :events() function can (optionally) return a number; which is the bitset of POLLIN, POLLOUT, etc?

@wahern
Copy link
Owner

wahern commented Oct 20, 2014

Committed.

@daurnimator
Copy link
Collaborator Author

Thanks! closed with b3d5284

@daurnimator
Copy link
Collaborator Author

P.S. you should add POLLPRI to the allowed mask

@wahern
Copy link
Owner

wahern commented Oct 20, 2014

I do need to add proper :recvmsg and :sendmsg calls which allow reading and sending OOB data, support SO_OOBINLINE as a socket option, etc. It's just not a high-priority at the moment. It will require careful testing across all the platforms.

I added the mask because the assignment is a signed, narrowing conversion (.events is a short) and I was just trying to be conscientious about undefined behavior. I only included POLLIN and POLLOUT in the mask because those are the only events currently supported. I could have made the mask 0x7fff but figured it was more prudent to filter out values which previously wouldn't have been seen.

@daurnimator
Copy link
Collaborator Author

I do need to add proper :recvmsg and :sendmsg calls which allow reading and sending OOB data, support SO_OOBINLINE as a socket option, etc. It's just not a high-priority at the moment.

I totally understand that.

I only included POLLIN and POLLOUT in the mask because those are the only events currently supported.

By the cqueues socket library....
But in one use case, I'm just using cqueues to dispatch between various C libraries.
e.g. I'm waiting on the next event from one of: libpq (postgres), hiredis or libdbus: they all just give me a socket and a poll mask, then I let them process their own fds.

@wahern
Copy link
Owner

wahern commented Oct 20, 2014

The code has to translate POLLIN and POLLOUT to the subsystem-specific flag. For Linux it's easy because POLLIN, POLLOUT, and POLLPRI are identical to EPOLLIN, EPOLLOUT, and EPOLLPRI. I think Solaris just reuses POLLIN directly.

However, for kqueue I haven't researched the issue. Some quick Googling turned up EV_OOBAND, but it's not documented in the OS X man page, and it doesn't even exist on OpenBSD.

The only application I know of off-hand that uses OOB data is telnet. FWIW, a grep through the PostgreSQL sources, for example, doesn't turn up any matches for "POLLPRI" or "MSG_OOB".

@daurnimator
Copy link
Collaborator Author

yeah this is low priority compared to my other issues. I knew how easy it would be for EPOLL; but didn't consider the other platforms.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants