Skip to content

Fix generic client removal deadlocks, add DeviceSet fallback and dedup - #42

Open
viacheslauK wants to merge 13 commits into
improvements-for-generic-clientfrom
review-for/improvements-for-generic-client
Open

viacheslauK wants to merge 13 commits into
improvements-for-generic-clientfrom
review-for/improvements-for-generic-client

Conversation

@viacheslauK

@viacheslauK viacheslauK commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Review follow-ups for the generic OPC UA client: removing a monitored item no longer waits for a sample in progress (fixes deadlocks with reconnect revalidation and application callbacks), device info falls back to the server's DeviceSet, and samples with an already published domain timestamp are not republished.

Changes

  • Device info: the node from DeviceNodeID* is tried first; if it is not set, missing or gives no device info, the single device referenced by DeviceSet is used.
  • Local ID: requires SerialNumber — <Manufacturer>_<SerialNumber>, or <SerialNumber> alone; otherwise the ApplicationUri.
  • Monitored item: processSample() drops a sample whose domain timestamp was already published; onConnectionRestored() no longer takes the config lock and keeps configErr.
  • Scheduler: registerItem() takes an owner that is kept alive during each call into the item; unregisterItem() no longer waits; lost wakeup on reconnect fixed.
  • Device: DefaultSamplingInterval limited to 1..UINT32_MAX via property min/max.
  • Tests: DI model and read counter in OpcUaServerTestHelper; new tests for the above; unconditional sleeps replaced with waits for processed samples.
  • Docs: USAGE.md covers the DeviceSet fallback and removal rules for callbacks.

Notes

  • removeFunctionBlock() may return while a sample is still running; the block is destroyed once the scheduler lets go of it.

…idation on reconnect

remove() holds the config lock of the block while it waits for the scheduler,
and onConnectionRestored() took the same lock on the scheduler thread.
It now relies on processingMutex only.
…for a sample

The wait happened under the config locks of the device, its FB folder and the block.
A core event handler or reader callback running inside that sample and
reading the block or the device deadlocked with the removal.
…waiting on removal

The scheduler takes a reference to the block for the duration of each call;
removing a block no longer waits for a sample in progress.
@viacheslauK viacheslauK changed the title Review for/improvements for generic client Fix generic client removal deadlocks, add DeviceSet fallback and dedup Oct 6, 2026
@viacheslauK viacheslauK self-assigned this Oct 6, 2026
@viacheslauK
viacheslauK marked this pull request as ready for review October 6, 2026 18:09
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.

1 participant