On the kernel side, it is easy to avoid using the sys_epoll() interface. In the end, you have direct access to the kernel objects, there is no need to jump through hoops.
Each file object, including sockets, "redefines" the polling method in its file_operations "vtable". You can simply bypass all your sockets by calling ->poll() for each of them and periodically displaying or when there is no data available.
If sockets have fairly high traffic, you donβt need anything else.
API Note:
poll() requires the poll_table() argument, however, if you are not going to wait for it, you can safely initialize it to zero:
poll_table pt; init_poll_funcptr(&pt, NULL); ... // struct socket *sk; ... unsigned event_mask = sk->ops->poll(sk->file, sk, &pt);
If you want to wait, just play around with the callback set in poll_table to init_poll_funcptr() .
oakad
source share