Skip to content

Conversation

@PawelStroinski
Copy link
Contributor

The existing-channel option added in #748 works only with NIO transport (Aleph default). When trying to use it with epoll, we would get a Netty error: incompatible event loop type: io.netty.channel.epoll.EpollEventLoop.

This is not surprising, since the server-channel class to use depends on the transport, as per
transport-server-channel-class and the existing-channel handling was always creating a NIO server-channel regardless of transport.

It’s not difficult to support most of the other transports. We just have to use the server-channel class as per the aforementioned fn. Their constructors in case of epoll and kqueue take an FD number rather than Java channel. There is no suitable constructor for io-uring, so it is not supported. The validation has been updated accordingly.

The full integration test is still limited to NIO, because obtaining an FD of a server-socket opened in Java requires deep reflection (the --add-opens flag), which would add some complexity (perhaps a dedicated lein profile) just to test this. The validation test checks that the FD route is attempted for the other transports, but it stops at Bad file descriptor error.

The option is being renamed from existing-channel to listen-socket, because this seems more fitting when we are accepting not just channels but also FDs. The existing-channel was merged very recently and hasn’t yet been released in a maven version.

The `existing-channel` option added in clj-commons#748 works only with NIO
transport (Aleph default). When trying to use it with epoll, we would
get a Netty error: `incompatible event loop type:
io.netty.channel.epoll.EpollEventLoop`.

This is not surprising, since the server-channel class to use depends
on the transport, as per
[`transport-server-channel-class`](https://github.com/clj-commons/aleph/blob/5a0c6976aa42f30ca3786cef64f9ba70cf037ae1/src/aleph/netty.clj#L1327)
and the `existing-channel` handling was always creating a NIO
server-channel regardless of transport.

It’s not difficult to support most of the other transports. We just
have to use the server-channel class as per the aforementioned fn.
Their constructors in case of epoll and kqueue take an FD number
rather than Java channel. There is no suitable constructor for
io-uring, so it is not supported. The validation has been updated
accordingly.

The full integration test is still limited to NIO, because obtaining
an FD of a server-socket opened in Java requires deep reflection
(the `--add-opens` flag), which would add some complexity (perhaps a
dedicated lein profile) just to test this. The validation test checks
that the FD route is attempted for the other transports, but it stops
at `Bad file descriptor` error.

The option is being renamed from `existing-channel` to
`listen-socket`, because this seems more fitting when we are accepting
not just channels but also FDs. The `existing-channel` was merged very
recently and hasn’t yet been released in a maven version.
@DerGuteMoritz
Copy link
Collaborator

Ah very nice! Glad I didn't yet get around to tagging a new release 😅 Thanks!

@DerGuteMoritz DerGuteMoritz merged commit bb3a1f1 into clj-commons:master Jun 21, 2025
1 check passed
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

Successfully merging this pull request may close these issues.

2 participants