feat(server): make server alloc-free on bare_metal, and surface inbound non-SD unicast#124
Open
FelicianoAngulo2 wants to merge 3 commits into
Open
feat(server): make server alloc-free on bare_metal, and surface inbound non-SD unicast#124FelicianoAngulo2 wants to merge 3 commits into
FelicianoAngulo2 wants to merge 3 commits into
Conversation
JustinKovacich
requested changes
Jun 1, 2026
JustinKovacich
left a comment
Contributor
There was a problem hiding this comment.
Looks good overall, I hope this is helpful. I've made a couple code quality requests/suggestions.
564ff3f to
29704df
Compare
9cafba0 to
892cb5b
Compare
…estCallback Two related changes to land the no-alloc bare-metal server path: 1. drop _alloc from the server feature and gate every alloc usage (use alloc::sync::Arc, Wrappable handles, SocketOptions, sd-protocol import, run_inner's 64 KiB vec! and new_with_deps/new_passive_with_deps' Arc-wrap constructors) so client+server+bare_metal builds with zero __rust_alloc/__rg_alloc symbol references. The Server struct's started latch is now a feature-gated StartedLatch type alias (Arc<AtomicBool> under _alloc, &'static AtomicBool on bare metal) passed through ServerStorage; the H/Hsd/Hep default generics use cfg'd DefaultSocketHandle/DefaultSdStateHandle/DefaultEventPublisherHandle aliases so Arc names don't need to resolve under no-alloc. StaticSubscriptionHandle returns core::future::Ready instead of alloc::boxed::Box::pin (the lock closures are synchronous). 2. Add NonSdRequestCallback fn-pointer on ServerStorage/Server, threaded through run_with_buffers/run_combined/recv_loop, invoked in place of the historical 'non-SD ignored' branch — surfaces method requests / fire-and-forget calls (e.g. halo's HWP1* requests) to the consumer FFI without requiring a ChannelFactory-backed ServerUpdates channel.
add non-SD observer support and no-alloc witness tests Co-authored-by: Justin Kovacich <32140377+JustinKovacich@users.noreply.github.com>
d198b30 to
64fcc08
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors the server implementation to fully support no-allocator ("no-alloc") builds and adds a new callback mechanism for handling non-Service Discovery (non-SD) SOME/IP unicast datagrams (i.e., method requests). It separates allocator-backed conveniences from the core, making the
serverfeature alloc-free unless explicitly requested. The pull request also updates the subscription handling for bare-metal/no-alloc targets to avoid heap allocations and clarifies the roles of various type aliases and generic parameters.The most important changes are:
No-alloc support and feature gating
serverfeature is now alloc-free by default; allocator-backed conveniences (such as heap-allocated buffers andArc-based handles) are gated behind the_allocfeature. The default handle types (DefaultSocketHandle,DefaultSdStateHandle,DefaultEventPublisherHandle) switch betweenArc<T>and&'static Tdepending on allocator availability. (Cargo.toml[1]src/server/mod.rs[2] [3]StartedLatchtype (used to prevent multiple run-futures from racing) is nowArc<AtomicBool>on alloc builds and&'static AtomicBoolon no-alloc builds, ensuring correct ownership and thread-safety for both cases. (src/server/mod.rs[1] [2]Non-SD SOME/IP datagram callback
non_sd_observercallback (NonSdRequestCallback) to theServerstruct and runtime. When set, this callback is invoked for every non-SD unicast datagram received, allowing consumers to handle SOME/IP method requests or fire-and-forget calls. (src/server/mod.rs[1] [2] [3] [4] [5] [6]Subscription handling for bare-metal/no-alloc
no_std) implementation ofSubscriptionHandlenow returnscore::future::Readyfutures instead of boxed heap-allocated futures, eliminating the need forallocin the no-alloc path. (src/server/subscription_manager.rs[1] [2] [3] [4]API and type exports
NonSdRequestCallbacktype and ensure all relevant types are available when theserverfeature is enabled. (src/lib.rssrc/lib.rsL228-R230)Internal code organization and tests
started,non_sd_observer) correctly, and added#[cfg(feature = "_alloc")]guards to allocator-specific methods. (src/server/mod.rs[1] [2] [3] [4] [5]These changes improve flexibility and portability for embedded and bare-metal targets, while also making the server more extensible for advanced SOME/IP use cases.