client: use go-winio.DialPipe directly#50125
Conversation
|
|
||
| // dialPipeContext connects to a Windows named pipe. It is not supported on non-Windows. | ||
| func dialPipeContext(ctx context.Context, string) (net.Conn, error) { | ||
| return nil, syscall.EAFNOSUPPORT |
There was a problem hiding this comment.
We could probably change this to ErrProtocolNotAvailable (or any other error?) 🤔
The go-connections package implementation is only a shallow wrapper around go-winio for named pipes; use the go-winio implementation directly. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
3bdd26c to
accbfde
Compare
| return sockets.DialPipe(cli.addr, 32*time.Second) | ||
| ctx, cancel := context.WithTimeout(ctx, 32*time.Second) | ||
| defer cancel() | ||
| return dialPipeContext(ctx, cli.addr) |
There was a problem hiding this comment.
🫠 looks like testutil has its own separate implementation of all of this
moby/testutil/request/npipe_windows.go
Lines 10 to 12 in c29de52
moby/testutil/request/request.go
Lines 197 to 224 in c29de52
There was a problem hiding this comment.
Pull Request Overview
This PR replaces the shallow go-connections wrapper for Windows named pipes with direct calls to go-winio’s DialPipeContext, and provides a stub on non-Windows platforms.
- Introduces
dialPipeContextinclient_windows.goto forward towinio.DialPipeContextwith context support - Adds a stub
dialPipeContextinclient_unix.gothat returnsEAFNOSUPPORT - Updates the main
dialerto use the newdialPipeContext(with timeout) instead ofsockets.DialPipe
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| client/client_windows.go | Added dialPipeContext forwarding to winio.DialPipeContext |
| client/client_unix.go | Added unsupported stub for non-Windows dialPipeContext |
| client/client.go | Switched npipe case to use new dialPipeContext with timeout |
Comments suppressed due to low confidence (2)
client/client_unix.go:15
- Update this comment to accurately describe the stub behavior on non-Windows, e.g., that
dialPipeContextalways returnssyscall.EAFNOSUPPORTon Unix.
// dialPipeContext connects to a Windows named pipe. It is not supported on non-Windows.
client/client_windows.go:15
- [nitpick] Add unit tests for
dialPipeContextto verify successful connections and context timeout handling on Windows.
func dialPipeContext(ctx context.Context, addr string) (net.Conn, error) {
The go-connections package implementation is only a shallow wrapper around go-winio for named pipes; use the go-winio implementation directly.
- How to verify it
- Human readable description for the release notes
- A picture of a cute animal (not mandatory but encouraged)