Skip to content

Commit 191540b

Browse files
committed
Support Unix Domain Sockets with io_uring transport
In Netty 4.2, Unix Domain Sockets with io_uring are supported. But they were not integrated by Vert.x yet. Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
1 parent 3924e93 commit 191540b

1 file changed

Lines changed: 21 additions & 20 deletions

File tree

vertx-core/src/main/java/io/vertx/core/impl/transports/IoUringTransport.java

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011-2024 Contributors to the Eclipse Foundation
2+
* Copyright (c) 2011-2026 Contributors to the Eclipse Foundation
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License 2.0 which is available at
@@ -8,6 +8,7 @@
88
*
99
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
1010
*/
11+
1112
package io.vertx.core.impl.transports;
1213

1314
import io.netty.bootstrap.Bootstrap;
@@ -16,6 +17,7 @@
1617
import io.netty.channel.socket.DatagramChannel;
1718
import io.netty.channel.socket.InternetProtocolFamily;
1819
import io.netty.channel.unix.DomainSocketAddress;
20+
import io.netty.channel.unix.UnixChannelOption;
1921
import io.netty.channel.uring.*;
2022
import io.vertx.core.datagram.DatagramSocketOptions;
2123
import io.vertx.core.net.TcpConfig;
@@ -61,7 +63,7 @@ public IoUringTransport() {
6163

6264
@Override
6365
public boolean supportsDomainSockets() {
64-
return false;
66+
return true;
6567
}
6668

6769
@Override
@@ -72,7 +74,7 @@ public boolean supportFileRegion() {
7274
@Override
7375
public SocketAddress convert(io.vertx.core.net.SocketAddress address) {
7476
if (address.isDomainSocket()) {
75-
throw new IllegalArgumentException("Domain socket not supported by IOUring transport");
77+
return new DomainSocketAddress(address.path());
7678
}
7779
return Transport.super.convert(address);
7880
}
@@ -113,15 +115,15 @@ public ChannelFactory<? extends DatagramChannel> datagramChannelFactory() {
113115
@Override
114116
public ChannelFactory<? extends Channel> channelFactory(boolean domainSocket) {
115117
if (domainSocket) {
116-
throw new IllegalArgumentException();
118+
return IoUringDomainSocketChannel::new;
117119
}
118120
return IoUringSocketChannel::new;
119121
}
120122

121123
@Override
122124
public ChannelFactory<? extends ServerChannel> serverChannelFactory(boolean domainSocket) {
123125
if (domainSocket) {
124-
throw new IllegalArgumentException();
126+
return IoUringServerDomainSocketChannel::new;
125127
}
126128
return IoUringServerSocketChannel::new;
127129
}
@@ -134,26 +136,25 @@ public void configure(DatagramChannel channel, DatagramSocketOptions options) {
134136

135137
@Override
136138
public void configure(TcpConfig config, boolean domainSocket, ServerBootstrap bootstrap) {
137-
if (domainSocket) {
138-
throw new IllegalArgumentException();
139+
if (!domainSocket) {
140+
bootstrap.option(UnixChannelOption.SO_REUSEPORT, config.isSoReusePort());
141+
configOption(bootstrap, config, TcpOption.FASTOPEN, IoUringChannelOption.TCP_FASTOPEN);
142+
configChildOption(bootstrap, config, TcpOption.USER_TIMEOUT, IoUringChannelOption.TCP_USER_TIMEOUT);
143+
configChildOption(bootstrap, config, TcpOption.QUICKACK, IoUringChannelOption.TCP_QUICKACK);
144+
configChildOption(bootstrap, config, TcpOption.CORK, IoUringChannelOption.TCP_CORK);
139145
}
140-
bootstrap.option(IoUringChannelOption.SO_REUSEPORT, config.isSoReusePort());
141-
configOption(bootstrap, config, TcpOption.FASTOPEN, IoUringChannelOption.TCP_FASTOPEN);
142-
configChildOption(bootstrap, config, TcpOption.USER_TIMEOUT, IoUringChannelOption.TCP_USER_TIMEOUT);
143-
configChildOption(bootstrap, config, TcpOption.QUICKACK, IoUringChannelOption.TCP_QUICKACK);
144-
configChildOption(bootstrap, config, TcpOption.CORK, IoUringChannelOption.TCP_CORK);
145-
Transport.super.configure(config, false, bootstrap);
146+
Transport.super.configure(config, domainSocket, bootstrap);
146147
}
147148

148149
@Override
149150
public void configure(TcpConfig config, boolean domainSocket, Bootstrap bootstrap) {
150-
if (domainSocket) {
151-
throw new IllegalArgumentException();
151+
if (!domainSocket) {
152+
NioTransport.configOption(bootstrap, config, TcpOption.FASTOPEN_CONNECT,
153+
IoUringChannelOption.TCP_FASTOPEN_CONNECT);
154+
NioTransport.configOption(bootstrap, config, TcpOption.USER_TIMEOUT, IoUringChannelOption.TCP_USER_TIMEOUT);
155+
NioTransport.configOption(bootstrap, config, TcpOption.QUICKACK, IoUringChannelOption.TCP_QUICKACK);
156+
NioTransport.configOption(bootstrap, config, TcpOption.CORK, IoUringChannelOption.TCP_CORK);
152157
}
153-
NioTransport.configOption(bootstrap, config, TcpOption.FASTOPEN_CONNECT, IoUringChannelOption.TCP_FASTOPEN_CONNECT);
154-
NioTransport.configOption(bootstrap, config, TcpOption.USER_TIMEOUT, IoUringChannelOption.TCP_USER_TIMEOUT);
155-
NioTransport.configOption(bootstrap, config, TcpOption.QUICKACK, IoUringChannelOption.TCP_QUICKACK);
156-
NioTransport.configOption(bootstrap, config, TcpOption.CORK, IoUringChannelOption.TCP_CORK);
157-
Transport.super.configure(config, false, bootstrap);
158+
Transport.super.configure(config, domainSocket, bootstrap);
158159
}
159160
}

0 commit comments

Comments
 (0)