Repository navigation
fix(cpworker): serve concurrent and split control-socket requests - #304
Merged
Merged
Conversation
- listen with a SOMAXCONN backlog instead of 1, so clients that connect at the same time (cpdaemon's stats poll and a cpctl call) are queued rather than failing with EAGAIN (#260) - bound the handshake read in accept with SO_RCVTIMEO (1 s): a client that connects and never sends the handshake no longer stalls the manager thread and every other client - a request split across writes is now read to its newline: select() was passed fd instead of fd + 1, the newline check used the last read's length instead of the buffered length, and a piece arriving on the third wait was read but then reported as incomplete (#261) The protocol stays strict request/response; pipelined requests are not supported. Tests: TestControlSocket integration test (concurrent clients, split request, silent client).
This was referenced Oct 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Concurrent clients (cpworker: control socket listen backlog is 1; concurrent Go clients fail with EAGAIN #260). The control socket listened with a backlog of 1. Go dials unix sockets non-blocking, so a second client connecting while the first was pending failed at once with
EAGAIN(e.g. cpdaemon's stats poll overlapping acpctlcall). The backlog is nowSOMAXCONN.Silent client.
acceptreads the handshake synchronously in the manager thread, and the socket had no receive timeout. A client that connected and never sent the handshake stalled the manager, and with it every other client. The handshake read is now bounded bySO_RCVTIMEO(1 s).Request split across writes (cpworker: control socket does not frame requests by newline; split or pipelined requests get no reply #261). The code meant to wait for the rest of a request, but:
select()was passedfdinstead offd + 1, so the fd was never examined and the wait always timed out;The loop is restructured to read until the newline; most of the diff in
unix_client_recvis re-indentation.The protocol stays strict request/response. Pipelined requests (several requests in one write, or the handshake and the first request together) are not supported; the only client,
cpgolib/cpworker/unix_client.go, waits for each reply before sending the next request. The constraint is documented atunix_client_recv.Tests
New integration test
TestControlSocket(cpworker/tests/integration/control_socket_test.go):concurrent_clients(32 clients at once)request_split_across_writessilent_client_does_not_block_othersUnit tests (9/9), the full integration suite and
cpgolibtests pass.Fixes #260
Refs #261