On Sun, Feb 19, 2023 at 10:21 AM Gregory Nutt <spudan...@gmail.com> wrote:
> > fd_set is a 32bit array, the max fd number is hardcode to 256: > >https://github.com/apache/nuttx/blob/master/include/sys/select.h#L38-L91 > <https://github.com/apache/nuttx/blob/master/include/sys/select.h#L38-L91> > > I just found that and was sending an email. I could not find where > select() or poll() are implemented in the nuttx repository. Is there some > kind of magic going on with that? > > They hare here: https://github.com/apache/nuttx/blob/master/fs/vfs/fs_select.c https://github.com/apache/nuttx/blob/master/fs/vfs/fs_poll.c > > it's better to define FD_SETSIZE to OPEN_MAX. > > That was my suggestion too.. > > Here is the patch: https://github.com/apache/nuttx/pull/8581 > > > On Sat, Feb 18, 2023 at 8:12 PM Xiang Xiao <xiaoxiang781...@gmail.com> > wrote: > > > fd_set is a 32bit array, the max fd number is hardcode to 256: > > https://github.com/apache/nuttx/blob/master/include/sys/select.h#L38-L91 > > it's better to define FD_SETSIZE to OPEN_MAX. > > > > > > On Sun, Feb 19, 2023 at 9:53 AM Gregory Nutt <spudan...@gmail.com> > wrote: > > > > > That is okay. My answer is possibly wrong anyway. OPEN_MAX is the > > maximum > > > number of open files. For the select, the file descriptor set was held > > in > > > a 32-bit bit set so the maximum was 31. But that logic has been > > redesigned > > > and I don’t know how it works now. > > > > > > > > > > > > Hopefully, it supports up to OPEN_MAX – 1, otherwise that would be a > bug. > > > > > > > > > > > > On Sat, Feb 18, 2023 at 7:37 PM KIKUCHI Takeyoshi < > > > kiku...@centurysys.co.jp> > > > wrote: > > > > > > > Hi Greg, > > > > > > > > Sorry, it seems that the same one was delivered late, probably > because > > I > > > > sent it with the wrong email source account (not the one I subscribed > > to > > > > the list). > > > > > > > > best regards, > > > > KIKUCHI Takeyoshi > > > > > > > > > > > > On 2023/02/19 9:20, Gregory Nutt wrote: > > > > > The maximum number of file descriptors is a constant value provided > > by > > > > > the preprocessor definition OPEN_MAX. > > > > > > > > > > On 2/16/2023 5:44 PM, KIKUCHI Takeyoshi wrote: > > > > >> currently porting the Nim language to NuttX. > > > > >> (It has been merged into the Nim devel branch) > > > > >> > > > > >> When using select/epoll, it is necessary to determine the maximum > > > > >> value of file descriptor in order to assign a structure to store > the > > > > >> fd to be waited in advance. > > > > >> > > > > >> It is used in this way. > > > > >> > > > > >> --------- > > > > >> proc newSelector*[T](): Selector[T] = > > > > >> # Retrieve the maximum fd count (for current OS) via getrlimit() > > > > >> var maxFD = maxDescriptors() <--- > > > > >> # Start with a reasonable size, checkFd() will grow this on demand > > > > >> const numFD = 1024 > > > > >> ... > > > > >> for i in 0 ... < numFD: > > > > >> result.fds[i].ident = InvalidIdent > > > > >> --------- > > > > >> (Now I realize that numFD also needs to be switched for NuttX...) > > > > >> > > > > >> Since the available memory capacity varies from device to device, > > > > >> Is there any way to find the best value for each build config? > > > > >> > > > > >> Porting to FreeRTOS in the Nim language uses the maximum number of > > > > >> sockets available, set by the user at build time. > > > > >> > > > > >> --------- > > > > >> var FD_MAX* {.importc: "CONFIG_LWIP_MAX_SOCKETS", header: > > > > >> "<lwipopts.h>".} : cint > > > > >> --------- > > > > >> > > > > >> best regards, > > > > >> KIKUCHI Takeyoshi > > > > >> > > > > > > > > > > > > > -- > > > > kiku...@centurysys.co.jp > > > > > > > > > >