LibVNC / libvncserver

LibVNCServer/LibVNCClient are cross-platform C libraries that allow you to easily implement VNC server or client functionality in your program.
GNU General Public License v2.0
1.08k stars 483 forks source link

[RFC] libvncclient: use poll() if available #528

Closed tobydox closed 1 year ago

tobydox commented 2 years ago

select() does not work with file descriptors > 1024 so use the more modern poll() function if available. This also avoids the overhead of allocating/managing the quite huge fd_set structure.

This is a draft and any feedback, especially about the proper usage of poll() in all 3 different cases (waiting for socket connection, waiting for data to be read, waiting for data to be written), is welcome. Of course if there are no objections, the changes also can be merged.

bk138 commented 2 years ago

Hi Toby, thanks for the PR!

Some general thoughts:

Are there more pros and cons you can think of? How would you weigh them?

Some resources I know of:

Thanks!

tobydox commented 2 years ago

We have customers who actually do establish many VNC connections in parallel on the one hand and on the other hand due to other components in the program allocating file descriptors (pipes, socket notifiers etc.), 1024 file descriptors in total are exceeded quickly. So yes complexity is increased but may be we can also find a better way of structuring the code besides macros (e.g. a polling wrapper which either uses poll() or select()).

bk138 commented 2 years ago

OK I see. Well my first plan was to use something like libev, libuv or libevent as a base, but I ended up thinking that implementing everything from scratch in Rust using tokio would be the very best approach ;-)

I'll do a in-depth review and then this can probably get merged as an incremental improvement.

tobydox commented 1 year ago

Patch rebased / ping