#730 net.server: Generic API for watching a file descriptor
Reporter
Zash
Owner
Zash
Created
Updated
Stars
★ (1)
Tags
Type-Enhancement
Status-Fixed
Priority-Medium
Milestone-0.11
Zash
on
Description of feature:
Sometimes we want to poll a FD that is not a TCP connection that should be entirely handled by net.server. Currently there are a few modules that do this using various hacks, including net.adns (for UDP), mod_auth_external (for a child process handle) and the libunbound integration someone wrote. server_event.addevent() is relatively nice but tied to libevent/luaevent.
So I propose a simple API like this be added to all net.server variants:
server.watchfd( fd, readcallback, writecallback ) → handle
where 'fd' would be either an integer or an object with a :getfd() method.
The handle should at the very least have a :close() method.
Zash
on
A way for the callbacks to change if it wants to wait for the FD to be readable, writable or both would also be good.
Eg by returning some special status code or a method on the handle.
Description of feature: Sometimes we want to poll a FD that is not a TCP connection that should be entirely handled by net.server. Currently there are a few modules that do this using various hacks, including net.adns (for UDP), mod_auth_external (for a child process handle) and the libunbound integration someone wrote. server_event.addevent() is relatively nice but tied to libevent/luaevent. So I propose a simple API like this be added to all net.server variants: server.watchfd( fd, readcallback, writecallback ) → handle where 'fd' would be either an integer or an object with a :getfd() method. The handle should at the very least have a :close() method.
A way for the callbacks to change if it wants to wait for the FD to be readable, writable or both would also be good. Eg by returning some special status code or a method on the handle.
This was apparently done in https://hg.prosody.im/trunk/rev/53178b6ba589
Changes