Skip to content

Delegate socket options and half-close in UnixSocket - #527

Merged
gesellix merged 1 commit into
mainfrom
fix/unix-socket-delegation
Dec 3, 2026
Merged

gesellix merged 1 commit into
mainfrom
fix/unix-socket-delegation

Conversation

@gesellix

@gesellix gesellix commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

UnixSocket wraps junixsocket's AFUNIXSocket, but only forwarded connect, the streams, bind, isConnected/isClosed and close. All other inherited java.net.Socket methods operated on the wrapper's own socket, which never gets connected:

NamedPipeSocket had the same class of bug, fixed in #526.

Change

  • Forward setSoTimeout/getSoTimeout (a value set before connect() is remembered and applied), shutdownInput/shutdownOutput, isInputShutdown/isOutputShutdown and isBound to the actual socket.
  • Without an explicit soTimeout, connect() keeps the previous default (read timeout = connect timeout).

Tests

UnixSocketTest uses an in-process AF_UNIX server (no Docker needed; runs on Linux, macOS and Windows 10+): half-close delivers EOF to the peer while the response can still be read, read timeout, soTimeout set before connect. The half-close and read-timeout tests fail against the previous implementation.

🤖 Generated with Claude Code

UnixSocket wraps an AFUNIXSocket, but the inherited java.net.Socket
methods operated on the wrapper's own SocketImpl, which never gets
connected:
- setSoTimeout() was a no-op, so OkHttp's readTimeout never applied
- shutdownOutput() failed with "SocketException: Not connected", e.g.
  when OkHttp closes the request body of a hijacked attach/exec stream

Delegate SO_TIMEOUT (remembering a value set before connect), half-close
and the related state queries to the actual socket.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gesellix
gesellix merged commit 0d364d7 into main Dec 3, 2026
5 checks passed
@gesellix
gesellix deleted the fix/unix-socket-delegation branch December 3, 2026 22:14
gesellix added a commit to gesellix/docker-client that referenced this pull request Dec 3, 2026
Named pipe fixes for WCOW (docker-client/docker-filesocket#526) and
UnixSocket timeout/half-close delegation (docker-client/docker-filesocket#527).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gesellix added a commit to docker-client/docker-remote-api-client that referenced this pull request Dec 3, 2026
Named pipe fixes for WCOW (docker-client/docker-filesocket#526) and
UnixSocket timeout/half-close delegation (docker-client/docker-filesocket#527).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gesellix added a commit to docker-client/docker-remote-api-client that referenced this pull request Dec 3, 2026
Named pipe fixes for WCOW (docker-client/docker-filesocket#526) and
UnixSocket timeout/half-close delegation (docker-client/docker-filesocket#527).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gesellix added a commit to gesellix/docker-client that referenced this pull request Dec 3, 2026
Named pipe fixes for WCOW (docker-client/docker-filesocket#526) and
UnixSocket timeout/half-close delegation (docker-client/docker-filesocket#527).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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