summary refs log tree commit diff stats
path: root/lib/pure/ioselects
diff options
context:
space:
mode:
authorCentury Systems <centurysys@users.noreply.github.com>2023-02-23 03:53:04 +0900
committerGitHub <noreply@github.com>2023-02-22 13:53:04 -0500
commitab1d4a5d58af8452b26f57f244bcd0d39b409c5e (patch)
tree077cfa7ce93fa60811de68a3690779c91dbe667a /lib/pure/ioselects
parent64a788cafb287ace8c63f5e86cb84c520eab3f2a (diff)
downloadNim-ab1d4a5d58af8452b26f57f244bcd0d39b409c5e.tar.gz
ioselectors_epoll: for NuttX, limit initial numFD to configured value. (#21421)
ioselectors: ioselectors_epoll: for NuttX, limit initial numFD to configured value.

In the NuttX build config, there is a setting called "FS_NEPOLL_DESCRIPTORS".

--------
config FS_NEPOLL_DESCRIPTORS
	int "Maximum number of default epoll descriptors for epoll_create1(2)"
	default 8
	---help---
		The maximum number of default epoll descriptors for epoll_create1(2)
--------

For NuttX, change the number of fd arrays allocated by newSelector() to that value.

Signed-off-by: Takeyoshi Kikuchi <kikuchi@centurysys.co.jp>
Diffstat (limited to 'lib/pure/ioselects')
-rw-r--r--lib/pure/ioselects/ioselectors_epoll.nim7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/pure/ioselects/ioselectors_epoll.nim b/lib/pure/ioselects/ioselectors_epoll.nim
index 8526eb8a3..08cb6ed74 100644
--- a/lib/pure/ioselects/ioselectors_epoll.nim
+++ b/lib/pure/ioselects/ioselectors_epoll.nim
@@ -72,11 +72,16 @@ type
   SelectEvent* = ptr SelectEventImpl
 
 proc newSelector*[T](): Selector[T] =
+  proc initialNumFD(): int {.inline.} =
+    when defined(nuttx):
+      result = NEPOLL_MAX
+    else:
+      result = 1024
   # Retrieve the maximum fd count (for current OS) via getrlimit()
   var maxFD = maxDescriptors()
   doAssert(maxFD > 0)
   # Start with a reasonable size, checkFd() will grow this on demand
-  const numFD = 1024
+  let numFD = initialNumFD()
 
   var epollFD = epoll_create1(O_CLOEXEC)
   if epollFD < 0: