Skip to content

Connection reliability and TLS correctness fixes, with a new unit test suite. - #75

Open
adamshapiro0 wants to merge 17 commits into
masterfrom
tls-fixes
Open

Connection reliability and TLS correctness fixes, with a new unit test suite.#75
adamshapiro0 wants to merge 17 commits into
masterfrom
tls-fixes

Conversation

@adamshapiro0

Copy link
Copy Markdown
Contributor

New Features

  • [C Client] Add POLARIS_NO_NETWORK so callers can tell a device with no connectivity from an endpoint that rejected them
  • [Examples] Add a reconnect backoff to the connection_retry example
  • [Tests] Add unit tests for the C and C++ clients (actual network connection and API key not required)

Changes

  • [C Client] Default POLARIS_ENABLE_TLS to enabled when it is undefined
  • [C Client] Resolve endpoint addresses with getaddrinfo() and try every address returned rather than only the first
  • [C++ Client] Return from Disconnect() without waiting for an in-progress connection attempt to finish

Fixes

  • [C Client] Honor POLARIS_NO_PRINT consistently across the library
  • [C Client] Time out connection attempts after POLARIS_CONNECT_TIMEOUT_MS instead of blocking on an unresponsive endpoint
  • [C Client] Suppress SIGPIPE on socket sends so losing connectivity mid-session reports EPIPE instead of killing the application with exit code 141
  • [C Client] Refuse to connect when TLS is requested but not compiled in, which previously downgraded silently
  • [C Client] Report a canceled connection attempt as POLARIS_CONNECTION_CLOSED whether the disconnect arrives before or during the connect
  • [C Client] Size the port string buffer for any int, fixing a -Wformat-truncation failure at -O2
  • [C++ Client] Stop counting failed connection attempts against the reconnect limit
  • [C++ Client] Reset the reconnect backoff once corrections are flowing, instead of leaving a session with repeated drops pinned at the maximum delay

The delay previously only reset on a user-requested disconnect, so a session
with recurring drops stayed pinned at the maximum. Waiting on a condition
variable instead of polling also lets Disconnect() interrupt the delay
immediately rather than up to 100 ms later.
The macro documented itself as enabled by default but fell back to 0, so
compiling the library without the build system's flags silently produced a
plaintext-only client. The build files now state the disabled case explicitly
rather than relying on the default.
Clearing the flag meant a caller that asked for TLS and did not check the
return value silently got an unencrypted connection, which for the
authentication request means sending the API key in the clear.
A disconnect requested before the address loop returned a socket error while
one requested during the connect returned POLARIS_CONNECTION_CLOSED, so the
code a caller saw depended on timing.
The port is not range checked before being formatted, so a six byte buffer
tripped -Wformat-truncation at -O2.
The corrections service publishes no AAAA records, so requesting IPv6 offered
support the network cannot provide.
@adamshapiro0
adamshapiro0 requested a review from anathan August 20, 2026 14:57
@adamshapiro0 adamshapiro0 self-assigned this Aug 20, 2026
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