Skip to content

Commit 162ce8d

Browse files
authored
liburing: Fix/allow configurable disable (#39695)
Signed-off-by: Ryan Northey <ryan@synca.io>
1 parent d1723fd commit 162ce8d

File tree

4 files changed

+47
-16
lines changed

4 files changed

+47
-16
lines changed

bazel/BUILD

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,3 +1058,18 @@ cc_library(
10581058
"//conditions:default": ["//bazel/foreign_cc:gperftools"],
10591059
}),
10601060
)
1061+
1062+
bool_flag(
1063+
name = "enable_liburing",
1064+
build_setting_default = True,
1065+
)
1066+
1067+
config_setting(
1068+
name = "liburing_enabled",
1069+
constraint_values = [
1070+
"@platforms//os:linux",
1071+
],
1072+
flag_values = {
1073+
":enable_liburing": "True",
1074+
},
1075+
)

source/common/io/BUILD

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,33 @@ envoy_package()
1111
envoy_cc_library(
1212
name = "io_uring_impl_lib",
1313
srcs = select({
14-
"//bazel:linux": ["io_uring_impl.cc"],
14+
"//bazel:liburing_enabled": ["io_uring_impl.cc"],
15+
"//conditions:default": [],
16+
}),
17+
hdrs = select({
18+
"//bazel:liburing_enabled": ["io_uring_impl.h"],
1519
"//conditions:default": [],
1620
}),
17-
hdrs = [
18-
"io_uring_impl.h",
19-
],
2021
tags = ["nocompdb"],
2122
deps = [
22-
"//bazel/foreign_cc:liburing_linux",
2323
"//envoy/common/io:io_uring_interface",
2424
"//envoy/thread_local:thread_local_interface",
25-
],
25+
] + select({
26+
"//bazel:liburing_enabled": ["//bazel/foreign_cc:liburing_linux"],
27+
"//conditions:default": [],
28+
}),
2629
)
2730

2831
envoy_cc_library(
2932
name = "io_uring_worker_lib",
3033
srcs = select({
31-
"//bazel:linux": ["io_uring_worker_impl.cc"],
34+
"//bazel:liburing_enabled": ["io_uring_worker_impl.cc"],
35+
"//conditions:default": [],
36+
}),
37+
hdrs = select({
38+
"//bazel:liburing_enabled": ["io_uring_worker_impl.h"],
3239
"//conditions:default": [],
3340
}),
34-
hdrs = ["io_uring_worker_impl.h"],
3541
deps = [
3642
":io_uring_impl_lib",
3743
"//envoy/common/io:io_uring_interface",
@@ -43,8 +49,14 @@ envoy_cc_library(
4349

4450
envoy_cc_library(
4551
name = "io_uring_worker_factory_impl_lib",
46-
srcs = ["io_uring_worker_factory_impl.cc"],
47-
hdrs = ["io_uring_worker_factory_impl.h"],
52+
srcs = select({
53+
"//bazel:liburing_enabled": ["io_uring_worker_factory_impl.cc"],
54+
"//conditions:default": [],
55+
}),
56+
hdrs = select({
57+
"//bazel:liburing_enabled": ["io_uring_worker_factory_impl.h"],
58+
"//conditions:default": [],
59+
}),
4860
deps = [
4961
":io_uring_worker_lib",
5062
"//envoy/common/io:io_uring_interface",

source/common/network/BUILD

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ envoy_cc_library(
249249
"win32_socket_handle_impl.cc",
250250
] + select({
251251
"//bazel:android": [],
252-
"//bazel:linux": [
252+
"//bazel:liburing_enabled": [
253253
"io_uring_socket_handle_impl.cc",
254254
],
255255
"//conditions:default": [],
@@ -261,11 +261,15 @@ envoy_cc_library(
261261
"win32_socket_handle_impl.h",
262262
] + select({
263263
"//bazel:android": [],
264-
"//bazel:linux": [
264+
"//bazel:liburing_enabled": [
265265
"io_uring_socket_handle_impl.h",
266266
],
267267
"//conditions:default": [],
268268
}),
269+
defines = select({
270+
"//bazel:liburing_enabled": ["ENVOY_ENABLE_IO_URING=1"],
271+
"//conditions:default": [],
272+
}),
269273
deps = [
270274
":address_lib",
271275
":io_socket_error_lib",
@@ -281,7 +285,7 @@ envoy_cc_library(
281285
"@envoy_api//envoy/extensions/network/socket_interface/v3:pkg_cc_proto",
282286
] + select({
283287
"//bazel:android": [],
284-
"//bazel:linux": [
288+
"//bazel:liburing_enabled": [
285289
"//source/common/io:io_uring_impl_lib",
286290
"//source/common/io:io_uring_worker_factory_impl_lib",
287291
"//source/common/io:io_uring_worker_lib",

source/common/network/socket_interface_impl.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "source/common/network/io_socket_handle_impl.h"
1212
#include "source/common/network/win32_socket_handle_impl.h"
1313

14-
#if defined(__linux__) && !defined(__ANDROID_API__)
14+
#if defined(__linux__) && !defined(__ANDROID_API__) && defined(ENVOY_ENABLE_IO_URING)
1515
#include "source/common/io/io_uring_worker_factory_impl.h"
1616
#include "source/common/io/io_uring_impl.h"
1717
#include "source/common/network/io_uring_socket_handle_impl.h"
@@ -40,7 +40,7 @@ IoHandlePtr SocketInterfaceImpl::makePlatformSpecificSocket(
4040
if constexpr (Event::PlatformDefaultTriggerType == Event::FileTriggerType::EmulatedEdge) {
4141
return std::make_unique<Win32SocketHandleImpl>(socket_fd, socket_v6only, domain);
4242
}
43-
#if defined(__linux__) && !defined(__ANDROID_API__)
43+
#if defined(__linux__) && !defined(__ANDROID_API__) && defined(ENVOY_ENABLE_IO_URING)
4444
// Only create IoUringSocketHandleImpl when the IoUringWorkerFactory has been created and it has
4545
// been registered in the TLS, initialized. There are cases that test may create threads before
4646
// IoUringWorkerFactory has been added to the TLS and got initialized.
@@ -167,7 +167,7 @@ bool SocketInterfaceImpl::ipFamilySupported(int domain) {
167167
Server::BootstrapExtensionPtr SocketInterfaceImpl::createBootstrapExtension(
168168
[[maybe_unused]] const Protobuf::Message& config,
169169
[[maybe_unused]] Server::Configuration::ServerFactoryContext& context) {
170-
#if defined(__linux__) && !defined(__ANDROID_API__)
170+
#if defined(__linux__) && !defined(__ANDROID_API__) && defined(ENVOY_ENABLE_IO_URING)
171171
const auto& message = MessageUtil::downcastAndValidate<
172172
const envoy::extensions::network::socket_interface::v3::DefaultSocketInterface&>(
173173
config, context.messageValidationVisitor());

0 commit comments

Comments
 (0)