RLIMIT_NOFILE as posix const
This commit is contained in:
parent
86c65db18d
commit
9e51e737b6
5 changed files with 13 additions and 8 deletions
|
|
@ -48,8 +48,6 @@ when not defined(android):
|
|||
proc signalfd(fd: cint, mask: var Sigset, flags: cint): cint
|
||||
{.cdecl, importc: "signalfd", header: "<sys/signalfd.h>".}
|
||||
|
||||
var RLIMIT_NOFILE {.importc: "RLIMIT_NOFILE",
|
||||
header: "<sys/resource.h>".}: cint
|
||||
type
|
||||
RLimit {.importc: "struct rlimit",
|
||||
header: "<sys/resource.h>", pure, final.} = object
|
||||
|
|
@ -82,7 +80,7 @@ type
|
|||
proc newSelector*[T](): Selector[T] =
|
||||
# Retrieve the maximum fd count (for current OS) via getrlimit()
|
||||
var a = RLimit()
|
||||
if getrlimit(RLIMIT_NOFILE, a) != 0:
|
||||
if getrlimit(posix.RLIMIT_NOFILE, a) != 0:
|
||||
raiseOsError(osLastError())
|
||||
var maxFD = int(a.rlim_max)
|
||||
doAssert(maxFD > 0)
|
||||
|
|
@ -528,4 +526,4 @@ template withData*[T](s: Selector[T], fd: SocketHandle|int, value, body1,
|
|||
body2
|
||||
|
||||
proc getFd*[T](s: Selector[T]): int =
|
||||
return s.epollFd.int
|
||||
return s.epollFd.int
|
||||
|
|
|
|||
|
|
@ -40,8 +40,6 @@ type
|
|||
wfd: cint
|
||||
SelectEvent* = ptr SelectEventImpl
|
||||
|
||||
var RLIMIT_NOFILE {.importc: "RLIMIT_NOFILE",
|
||||
header: "<sys/resource.h>".}: cint
|
||||
type
|
||||
rlimit {.importc: "struct rlimit",
|
||||
header: "<sys/resource.h>", pure, final.} = object
|
||||
|
|
@ -64,7 +62,7 @@ else:
|
|||
|
||||
proc newSelector*[T](): Selector[T] =
|
||||
var a = rlimit()
|
||||
if getrlimit(RLIMIT_NOFILE, a) != 0:
|
||||
if getrlimit(posix.RLIMIT_NOFILE, a) != 0:
|
||||
raiseIOSelectorsError(osLastError())
|
||||
var maxFD = int(a.rlim_max)
|
||||
|
||||
|
|
@ -317,4 +315,4 @@ template withData*[T](s: Selector[T], fd: SocketHandle|int, value, body1,
|
|||
|
||||
|
||||
proc getFd*[T](s: Selector[T]): int =
|
||||
return -1
|
||||
return -1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue