Skip to content

fix(libwaterlinked): harden TCP command handling#32

Open
Kurtuveys wants to merge 5 commits into
waterlinked:mainfrom
Kurtuveys:fix/dvl-driver-hardening
Open

fix(libwaterlinked): harden TCP command handling#32
Kurtuveys wants to merge 5 commits into
waterlinked:mainfrom
Kurtuveys:fix/dvl-driver-hardening

Conversation

@Kurtuveys

Copy link
Copy Markdown

Summary

This PR improves reliability of the Water Linked TCP client and callback handling.

The TCP command path had several reliability risks:

  • pending_requests_ was accessed from multiple threads without locking.
  • A fast DVL response could arrive before the promise was registered.
  • Pending command requests could remain unresolved when the DVL did not respond.
  • Pending requests were not failed explicitly when the TCP connection was lost.
  • The socket could leak if connection setup failed after socket() succeeded.
  • Report callback vectors could be modified while the polling thread was iterating over them.

Changes

  • Protect pending_requests_ with request_mutex_.
  • Register the pending promise before sending the command.
  • Add command response timeout handling.
  • Fail all pending commands on connection loss.
  • Close the socket on constructor connection failure paths.
  • Protect report callback registration and callback iteration with a mutex.

Validation

Tested with:

colcon build --packages-up-to waterlinked_dvl_driver
colcon test --packages-select libwaterlinked --event-handlers console_direct+
colcon test-result --verbose

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.

2 participants