Skip to content

Commit c561059

Browse files
authored
dynamic_modules: mark EnvoyHttpFilterScheduler as Sync since it's threadsafe (#41787)
Commit Message: dynamic_modules: mark EnvoyHttpFilterScheduler as Sync since it's threadsafe Additional Description: I noticed the dispatcher seems to be thread-safe https://github.com/envoyproxy/envoy/blob/d45e365e78ae391d4617d8b58236dbe67f8ebb28/source/common/event/dispatcher_impl.cc#L266 So it should be fine to mark the scheduler in dynamic modules as `Sync`. This would allow sharing it with `Arc` instead of having to use `new_scheduler` multiple times as I currently need to do. Risk Level: Low Testing: Unit tests Docs Changes: N/A Release Notes: N/A Platform Specific Features: None Signed-off-by: Anuraag Agrawal <[email protected]>
1 parent d45e365 commit c561059

File tree

1 file changed

+4
-1
lines changed
  • source/extensions/dynamic_modules/sdk/rust/src

1 file changed

+4
-1
lines changed

source/extensions/dynamic_modules/sdk/rust/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1999,8 +1999,10 @@ impl EnvoyHttpFilterImpl {
19991999
/// Since this is primarily designed to be used from a different thread than the one
20002000
/// where the [`HttpFilter`] instance was created, it is marked as `Send` so that
20012001
/// the [`Box<dyn EnvoyHttpFilterScheduler>`] can be sent across threads.
2002+
///
2003+
/// It is also safe to be called concurrently, so it is marked as `Sync` as well.
20022004
#[automock]
2003-
pub trait EnvoyHttpFilterScheduler: Send {
2005+
pub trait EnvoyHttpFilterScheduler: Send + Sync {
20042006
/// Commit the scheduled event to the worker thread where [`HttpFilter`] is running.
20052007
///
20062008
/// It accepts an `event_id` which can be used to distinguish different events
@@ -2019,6 +2021,7 @@ struct EnvoyHttpFilterSchedulerImpl {
20192021
}
20202022

20212023
unsafe impl Send for EnvoyHttpFilterSchedulerImpl {}
2024+
unsafe impl Sync for EnvoyHttpFilterSchedulerImpl {}
20222025

20232026
impl Drop for EnvoyHttpFilterSchedulerImpl {
20242027
fn drop(&mut self) {

0 commit comments

Comments
 (0)