Skip to content

Bound remote control client concurrency - #628

Open
onevtail wants to merge 7 commits into
mainfrom
relay/continue-55-support-remote-control-via-mobile-app-8674e1f1
Open

Bound remote control client concurrency#628
onevtail wants to merge 7 commits into
mainfrom
relay/continue-55-support-remote-control-via-mobile-app-8674e1f1

Conversation

@onevtail

Copy link
Copy Markdown
Collaborator

Builds on #583 by @onevclaw and preserves their commits.

What

  • Limit the read-only remote control bridge to 16 active client connections.
  • Reject excess sockets before dispatching blocking client work.
  • Quiesce the accept queue before shutting down registered clients, closing the accept/register race during stop().
  • Add regression coverage for connection-limit rejection, released-capacity reuse, and synchronous stalled-client shutdown.
  • Correct the mobile remote control work record and advance the manual sync baseline to the full implementation commit SHA.

Why

The existing per-connection timeout bounded individual requests, but unlimited concurrent admission could still cause GCD thread growth under a local connection flood. The shutdown ordering also left a narrow window in which an accepted socket could register after the active-connection shutdown sweep.

These changes bound resource usage and make shutdown ordering explicit without changing the bridge’s loopback-only, authenticated, read-only protocol.

How tested

  • make check
  • Focused xcodebuild test covering RemoteControlServerTests, router and token-store tests, and settings lifecycle/persistence tests: 58 passed, 0 failed
  • make build-app: 0 errors, 0 warnings

onevtail - an assistant to @onevcat

onevcat and others added 7 commits July 13, 2026 10:09
Address review feedback on the TCP server:

- Handle accepted clients on a concurrent queue so a half-open or slow
  client cannot block the accept loop or subsequent requests.
- Bound client I/O with per-socket timeouts plus a connection-level
  deadline, and clear inherited O_NONBLOCK on accepted sockets.
- Track in-flight client sockets and shut them down on stop() so a
  stalled client cannot outlive disable; closes stay single-owner to
  avoid double-close and descriptor-reuse races.
- Suppress SIGPIPE on client sockets so writes to disconnected peers
  fail recoverably instead of terminating the app.
- Accept via a dispatch read source that cancels without fd races and
  release the listening port synchronously on stop().
- Add TCP integration tests: half-open clients, disable/re-enable while
  a client is stalled, and abrupt disconnects before 400/401/200
  responses.

Claude-Session: https://claude.ai/code/session_01Mqcb3RcxubFSfwAMr1yUDQ
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.

3 participants