-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dynamic_modules: prevent multiple calls to init function (#38458)
Commit Message: dynamic_modules: prevent multiple calls to init function Additional Description: Previously, the program init function was called multiple times despite the semantics of the ABI. This fixes that by utilizing RTLD_NOLOAD flag of dlopen to check a shared library is already loaded. Risk Level: low Testing: done Docs Changes: n/a Release Notes: n/a Platform Specific Features: n/a --------- Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
- Loading branch information
Showing
6 changed files
with
52 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
test/extensions/dynamic_modules/test_data/c/program_init_assert.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <assert.h> | ||
|
||
#include "source/extensions/dynamic_modules/abi.h" | ||
#include "source/extensions/dynamic_modules/abi_version.h" | ||
|
||
envoy_dynamic_module_type_abi_version_envoy_ptr envoy_dynamic_module_on_program_init(void) { | ||
// This ensures that the init function is only called once during the test. | ||
static bool initialized = false; | ||
if (initialized) { | ||
assert(0); | ||
} | ||
initialized = true; | ||
return kAbiVersion; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -322,6 +322,7 @@ NOLINT | |
NOLINTBEGIN | ||
NOLINTEND | ||
NOLINTNEXTLINE | ||
NOLOAD | ||
NONAME | ||
NONBLOCK | ||
NONCES | ||
|