Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing socket to newDatagramTransport fails with Descriptor X already registered [AssertionDefect] #202

Open
bauerj opened this issue Jun 21, 2021 · 0 comments

Comments

@bauerj
Copy link
Contributor

bauerj commented Jun 21, 2021

Minimal example:

import chronos
import posix
import nativesockets

proc processClient(transp: DatagramTransport, raddr: TransportAddress):
    Future[void] {.async.} =
    discard 1

var x = 0
let ta = initTAddress("::", 9000)
let localSock = createAsyncSocket(ta.getDomain(), SockType.SOCK_DGRAM, nativesockets.Protocol.IPPROTO_UDP)
discard newDatagramTransport6(processClient, udata = addr x, local = ta, sock = localSock)

This fails with

/playground/nimble/chronos-3.0.2/chronos/transports/datagram.nim(694) newDatagramTransport6
/playground/nimble/chronos-3.0.2/chronos/transports/datagram.nim(533) newDatagramTransportCommon
/playground/nimble/chronos-3.0.2/chronos/asyncloop.nim(560) register
/playground/nimble/chronos-3.0.2/chronos/ioselects/ioselectors_epoll.nim(142) registerHandle
/playground/nim/lib/system/assertions.nim(30) failedAssertImpl
/playground/nim/lib/system/assertions.nim(23) raiseAssert
/playground/nim/lib/system/fatal.nim(49) sysFatal
Error: unhandled exception: /playground/nimble/chronos-3.0.2/chronos/ioselects/ioselectors_epoll.nim(142, 11) `s.fds[fdi].ident == InvalidIdent` Descriptor 3 already registered [AssertionDefect]

thus preventing to pass a custom socket to newDatagramTransport.

Calling createAsyncSocket already calls register so I'm not sure if it's necessary here. A workaround would be to use AsyncFD(createNativeSocket()) instead of createAsyncSocket().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant