c - Make select() crack without writing to a file desc? -
i have thread in application monitors set of client sockets. use select()
block until client makes request, can handle efficiently without multiplying threads.
now, problem is, when add new client list of clients, have wait timeout of select()
(set 10 seconds) add new socket listened sockets.
so i'd make select()
crack before timeout client can listened immediately.
i have solution that: create dummy socketpair include in listened sockets list, , in write make select()
crack, i'm hoping there's better solution out there.
edit: have no access eventfd()
because glibc use old (and have no mean update it). might have use fifo or socket.
do know any?
thanks!
the usual way of waking select loop add read end of pipe()
fd pair select's watching set. when need wake select loop, write dummy data write end of file descriptor.
note on linux might want consider using eventfd()
instead of pipe()
- may more efficient (although less portable).
you handle listen socket in select loop instead of handing off thread - wake select loop implicitly when new client comes.
Comments
Post a Comment