Skip to content

Replace mmap-based IPC with score_baselibs SharedMemoryFactory in ts_client#54

Open
gordon9901 wants to merge 4 commits into
eclipse-score:mainfrom
gordon9901:ecarx_pr2_shm_impl
Open

Replace mmap-based IPC with score_baselibs SharedMemoryFactory in ts_client#54
gordon9901 wants to merge 4 commits into
eclipse-score:mainfrom
gordon9901:ecarx_pr2_shm_impl

Conversation

@gordon9901

@gordon9901 gordon9901 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Replaces the hand-rolled POSIX shm_open/mmap implementation in ts_client
with score::memory::shared::SharedMemoryFactory from score_baselibs, and
wires up a new SvtHandlerShm timebase handler in TimeDaemon.

ts_client (score/ts_client/)

  • GptpIpcPublisher / GptpIpcReceiver: remove direct shm_open, mmap,
    ftruncate, close calls; use SharedMemoryFactory::Create /
    SharedMemoryFactory::Open instead. Memory region is now constructed via
    ISharedMemoryResource::construct<GptpIpcRegion>().
  • SharedMemoryFactory::Remove + RemoveStaleArtefacts replace the raw
    shm_unlink in publisher init.
  • Header guards updated to drop the redundant _SRC_ segment.

TimeDaemon (score/time_daemon/src/application/svt/)

  • New SvtHandlerShm (factory_shm.h/.cpp, svt_handler_shm.h/.cpp):
    a TimebaseHandler implementation that reads live gPTP data from shared
    memory via GPTPShmMachine and drives the same verification + IPC-publish
    pipeline as the existing SvtHandler.

fixes (#41)

@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown

License Check Results

🚀 The license check job ran with the Bazel command:

bazel run //:license-check

Status: ⚠️ Needs Review

Click to expand output
[License Check Output]
Extracting Bazel installation...
Starting local Bazel server (8.3.0) and connecting to it...
INFO: Invocation ID: 75bec5d3-5f08-4ec3-8e86-12b20d611d73
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
WARNING: For repository 'aspect_rules_lint', the root module requires module version [email protected], but got [email protected] in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
Computing main repo mapping: 
Loading: 
Loading: 2 packages loaded
Loading: 2 packages loaded
    currently loading: 
Loading: 2 packages loaded
    currently loading: 
Loading: 2 packages loaded
    currently loading: 
Loading: 2 packages loaded
    currently loading: 
Analyzing: target //:license-check (3 packages loaded, 0 targets configured)
Analyzing: target //:license-check (3 packages loaded, 0 targets configured)

Analyzing: target //:license-check (91 packages loaded, 9 targets configured)

Analyzing: target //:license-check (157 packages loaded, 5785 targets configured)

Analyzing: target //:license-check (169 packages loaded, 8049 targets configured)

Analyzing: target //:license-check (169 packages loaded, 8049 targets configured)

Analyzing: target //:license-check (172 packages loaded, 9937 targets configured)

Analyzing: target //:license-check (173 packages loaded, 10058 targets configured)

Analyzing: target //:license-check (173 packages loaded, 10058 targets configured)

INFO: Analyzed target //:license-check (174 packages loaded, 10184 targets configured).
[10 / 16] JavaToolchainCompileClasses external/rules_java+/toolchains/platformclasspath_classes; 0s disk-cache, processwrapper-sandbox ... (2 actions, 1 running)
INFO: From Generating Dash formatted dependency file ...:
INFO: Successfully converted 2 packages from Cargo.lock to bazel-out/k8-fastbuild/bin/formatted.txt
[15 / 16] [Prepa] Building license.check.license_check.jar ()
INFO: Found 1 target...
Target //:license.check.license_check up-to-date:
  bazel-bin/license.check.license_check
  bazel-bin/license.check.license_check.jar
INFO: Elapsed time: 33.774s, Critical Path: 1.87s
INFO: 16 processes: 12 internal, 3 processwrapper-sandbox, 1 worker.
INFO: Build completed successfully, 16 total actions
INFO: Running command line: bazel-bin/license.check.license_check ./formatted.txt <args omitted>
usage: org.eclipse.dash.licenses.cli.Main [-batch <int>] [-cd <url>]
       [-confidence <int>] [-ef <url>] [-excludeSources <sources>] [-help] [-lic
       <url>] [-project <shortname>] [-repo <url>] [-review] [-summary <file>]
       [-timeout <seconds>] [-token <token>]

@github-actions

Copy link
Copy Markdown

The created documentation from the pull request is available at: docu-html

Comment thread score/time_daemon/src/application/svt/svt_handler_shm.cpp Outdated
********************************************************************************/
#ifndef SCORE_TS_CLIENT_SRC_GPTP_IPC_H
#define SCORE_TS_CLIENT_SRC_GPTP_IPC_H
#ifndef SCORE_TS_CLIENT_GPTP_IPC_H

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and everywhere: Why doing this include guard renaming?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SRC segment encodes the physical directory path (ts_client/src/), which is an internal layout detail. Include guards should reflect the logical module name, not the filesystem structure — hence SCORE_TS_CLIENT_* rather than SCORE_TS_CLIENT_SRC_*. All 6 headers under ts_client/src/ were updated consistently.

@BjoernAtBosch BjoernAtBosch Jun 17, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I also see this. But I'm struggeling with the point, that the "physical" structure is also visible in the includes, e.g.

#include "score/ts_client/src/gptp_ipc_channel.h"

which then should also be

#include "score/ts_client/gptp_ipc_channel.h"

instead. But that's how it is in Bazel.

If we change it here, we would be inconsistent in the overall module and should change it everywhere. (Maybe not now)

Maybe there is some S-CORE convention. Lets check ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked the lifecycle repo — it uses strip_include_prefix + include_prefix in BUILD to remap physical paths to logical ones, so guards and include paths stay consistent. Should we do the same here (strip src/ in the BUILD and update all include sites), or keep it as a follow-up?

Comment thread score/ts_client/src/gptp_ipc_data.h Outdated
* @brief IPC data snapshot written by TimeSlave and read by TimeDaemon.
*
* This type is internal to ts_client/src and intentionally decoupled from
* This type is internal to libTSClient and intentionally decoupled from

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* This type is internal to libTSClient and intentionally decoupled from
* This type is internal to ts_client and intentionally decoupled from

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. This was an oversight — the comment should say ts_client, not libTSClient. Fixed.

{

/// Default POSIX shared memory name for the gPTP IPC channel.
constexpr char kGptpIpcName[] = "/gptp_ptp_info";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
constexpr char kGptpIpcName[] = "/gptp_ptp_info";
/// Default shared memory name for the gPTP IPC channel.
constexpr char kGptpIpcName[] = "/gptp_ptp_info";

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. The comment was removed because "POSIX" is no longer accurate after switching to SharedMemoryFactory. Restored as /// Default shared memory name for the gPTP IPC channel.

Comment thread score/ts_client/src/gptp_ipc_receiver.h Outdated

/// Open and map the shared memory segment (read-only).
/// @return true on success.
bool Init(const std::string& ipc_name = kGptpIpcName);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool Init(const std::string& ipc_name = kGptpIpcName);
bool Open(const std::string& ipc_name = kGptpIpcName);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Open/Close is more semantically precise and forms a natural pair. Renamed in both GptpIpcPublisher and GptpIpcReceiver, including all call sites and test cases.


/// Create and map the shared memory segment.
/// @return true on success.
bool Init(const std::string& ipc_name = kGptpIpcName);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool Init(const std::string& ipc_name = kGptpIpcName);
bool Open(const std::string& ipc_name = kGptpIpcName);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Open/Close is more semantically precise and forms a natural pair. Renamed in both GptpIpcPublisher and GptpIpcReceiver, including all call sites and test cases.

void Publish(const score::ts::GptpIpcData& data);

/// Unmap and unlink the shared memory segment.
void Destroy();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void Destroy();
void Close();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Open/Close is more semantically precise and forms a natural pair. Renamed in both GptpIpcPublisher and GptpIpcReceiver, including all call sites and test cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants