Skip to content

Commit bc82115

Browse files
committed
Fixes
Signed-off-by: Rohit Agrawal <[email protected]>
1 parent 1be310e commit bc82115

File tree

6 files changed

+14
-423
lines changed

6 files changed

+14
-423
lines changed

source/extensions/dynamic_modules/abi_version.h

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,14 @@
11
#pragma once
2-
32
#ifdef __cplusplus
4-
extern "C" {
3+
namespace Envoy {
4+
namespace Extensions {
5+
namespace DynamicModules {
56
#endif
6-
77
// This is the ABI version calculated as a sha256 hash of the ABI header files. When the ABI
88
// changes, this value must change, and the correctness of this value is checked by the test.
99
const char* kAbiVersion = "671102aad648320f21c53d1c04aa9780d1d2668e3e63e8a993d30a9029a168e4";
1010

1111
#ifdef __cplusplus
12-
} // extern "C"
13-
14-
namespace Envoy {
15-
namespace Extensions {
16-
namespace DynamicModules {
17-
namespace AbiVersion {
18-
// For C++ code, also provide the version in the namespace.
19-
constexpr const char kAbiVersion[] =
20-
"671102aad648320f21c53d1c04aa9780d1d2668e3e63e8a993d30a9029a168e4";
21-
} // namespace AbiVersion
2212
} // namespace DynamicModules
2313
} // namespace Extensions
2414
} // namespace Envoy

source/extensions/dynamic_modules/dynamic_modules.cc

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ constexpr char DYNAMIC_MODULES_SEARCH_PATH[] = "ENVOY_DYNAMIC_MODULES_SEARCH_PAT
1717

1818
absl::StatusOr<DynamicModulePtr>
1919
newDynamicModule(const std::filesystem::path& object_file_absolute_path, const bool do_not_close,
20-
const bool load_globally) {
20+
const bool load_globally) {
2121
// From the man page of dlopen(3):
2222
//
2323
// > This can be used to test if the object is already resident (dlopen() returns NULL if it
@@ -31,15 +31,10 @@ newDynamicModule(const std::filesystem::path& object_file_absolute_path, const b
3131
// loaded module. We don't need to call the init function again.
3232
return std::make_unique<DynamicModule>(handle);
3333
}
34+
// RTLD_LOCAL is always needed to avoid collisions between multiple modules.
3435
// RTLD_LAZY is required for not only performance but also simply to load the module, otherwise
3536
// dlopen results in Invalid argument.
36-
int mode = RTLD_LAZY;
37-
if (load_globally) {
38-
mode |= RTLD_GLOBAL;
39-
} else {
40-
// RTLD_LOCAL is used by default to avoid collisions between multiple modules.
41-
mode |= RTLD_LOCAL;
42-
}
37+
int mode = RTLD_LOCAL | RTLD_LAZY;
4338
if (do_not_close) {
4439
mode |= RTLD_NODELETE;
4540
}
@@ -65,9 +60,9 @@ newDynamicModule(const std::filesystem::path& object_file_absolute_path, const b
6560
absl::StrCat("Failed to initialize dynamic module: ", object_file_absolute_path.c_str()));
6661
}
6762
// Checks the kAbiVersion and the version of the dynamic module.
68-
if (absl::string_view(abi_version) != absl::string_view(AbiVersion::kAbiVersion)) {
69-
return absl::InvalidArgumentError(absl::StrCat("ABI version mismatch: got ", abi_version,
70-
", but expected ", AbiVersion::kAbiVersion));
63+
if (absl::string_view(abi_version) != absl::string_view(kAbiVersion)) {
64+
return absl::InvalidArgumentError(
65+
absl::StrCat("ABI version mismatch: got ", abi_version, ", but expected ", kAbiVersion));
7166
}
7267
return dynamic_module;
7368
}

source/extensions/dynamic_modules/sdk/rust/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ fn main() {
1818
println!("cargo:rerun-if-changed=abi.h");
1919
let bindings = bindgen::Builder::default()
2020
.header("../../abi.h")
21+
.header("../../abi_version.h")
2122
.clang_arg("-v")
2223
.default_enum_style(bindgen::EnumVariation::Rust {
2324
non_exhaustive: false,

0 commit comments

Comments
 (0)