Skip to content

Power devices: send Heartbeats on Linux and macOS (make the Handshaking thread its reactor's owner) - #34

Open
nyhnpya wants to merge 1 commit into
OpenDDS:mainfrom
nyhnpya:fix-power-device-heartbeat
Open

nyhnpya wants to merge 1 commit into
OpenDDS:mainfrom
nyhnpya:fix-power-device-heartbeat

Conversation

@nyhnpya

@nyhnpya nyhnpya commented Nov 19, 2026

Copy link
Copy Markdown

Fixes #33.

Problem

On Linux and macOS, the TMS power devices (Source, Load and Distribution) never send a Heartbeat. MIL-STD-3071 §B.4 requires one every second.

PowerDevice::run_i() runs the Handshaking reactor, which drives the Heartbeat timer, in a new thread. That reactor is created on the constructing thread. Off Windows it is an ACE_Select_Reactor, whose handle_events() returns -1 with EACCES when it isn't called from its owner thread (ace/Select_Reactor_T.cpp). So run_reactor_event_loop() returns at once, and the timer never fires. The Windows default (WFMO) has no owner check, which is probably why CI doesn't catch this.

Change

Make the new thread the reactor's owner before running its event loop (PowerDevice.h, a one-line change plus a comment).

Testing

macOS 15 arm64, OpenDDS master 01bb58f, built as in .github/workflows/TMS.yml. Controller, Source and Load ran on domain 11 with rtps_disc.ini, and Heartbeat DATA submessages were counted over 13 s:

Participants sending Heartbeat DATA
Before (cbbccf6) Controller only
After Controller, Source and Load (46 to 48 each)

A separate MIL-STD-3071 implementation on the same domain also saw all three devices only with the change.

…rtbeats are sent

PowerDevice::run_i() runs the Handshaking reactor, which drives the
Heartbeat timer, in a new thread. The reactor is created on the
constructing thread, and off Windows it is an ACE_Select_Reactor, whose
handle_events() returns -1 (EACCES) when it isn't called from its owner
thread. run_reactor_event_loop() then returns at once, so Source, Load and
Distribution never send a Heartbeat (MIL-STD-3071 §B.4) on Linux or macOS.

Make the new thread the reactor's owner before running its event loop.

Fixes OpenDDS#33
@mitza-oci
mitza-oci requested a review from sonndinh November 19, 2026 17:16

@sonndinh sonndinh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for contributing! The changes look good to me. I'll test it locally and get back to you.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TMS power devices never send Heartbeats on Linux/macOS: Handshaking reactor runs on a non-owner thread

2 participants