wolfSSL / wolfMQTT

wolfMQTT is a small, fast, portable MQTT client implementation, including support for TLS 1.3.
https://www.wolfssl.com
GNU General Public License v2.0
521 stars 155 forks source link

replace select() with a call able to handle >1024 filedescriptors #278

Open tabascoeye opened 2 years ago

tabascoeye commented 2 years ago

In this line: https://github.com/wolfSSL/wolfMQTT/blob/0ba0929bfc0fbaffd5a612ed9c79eefcd0aea134/examples/mqttnet.c#L672 a posix select() call is used. This is limited to handle a maxmium of 1024 filedescriptors in a system (overall, not only in that specific call!).

Depending on the system, this is not limited to sockets, but simple files as well. If the select() is then called wth an fd where the id is above 1024, the behavior is undefined, in most cases it just fails.

==> please replace this by e.g. poll() or other more modern mechanism for the scheme

embhorn commented 2 years ago

Hello @tabascoeye

Thanks for your suggestion! I will treat this as a feature request. The example client code is designed to be easy to understand and helpful for someone getting started. I think this feature will support those goals.

Could you tell us a bit about your project? Does the 1024 fd limit from select() impact you?

dgarske commented 1 year ago

Hi @tabascoeye ,

Thank you for the suggestion.

@embhorn , we have some examples for using poll vs select here: https://github.com/wolfSSL/wolfsentry/blob/naii_demo/examples/notification-demo/echo_server/echo.c#L530 https://github.com/wolfSSL/wolfsentry/blob/naii_demo/examples/notification-demo/echo_server/echo.c#L647

If you do add this support please make sure there is a build option to support either.

Thanks, David Garske, wolfSSL