diff --git a/weed/pb/grpc_client_server.go b/weed/pb/grpc_client_server.go index e26d6278b..b3aff37a9 100644 --- a/weed/pb/grpc_client_server.go +++ b/weed/pb/grpc_client_server.go @@ -8,6 +8,7 @@ import ( "net" "net/http" "os" + "runtime" "strconv" "strings" "sync" @@ -81,7 +82,15 @@ func init() { // GrpcDial to host:grpcPort (or to a loopback alias of host on the same // port) is routed through the Unix socket. Dials to any other host on the // same port still go over TCP. +// +// No-op on Windows: the /tmp/...sock paths callers pass are POSIX-only and +// the listen/dial would fail at runtime, taking gRPC down with it (#9430). +// Skipping registration leaves the maps empty, so ServeGrpcOnLocalSocket +// and resolveLocalGrpcSocket short-circuit and same-host RPCs go over TCP. func RegisterLocalGrpcSocket(host string, grpcPort int, socketPath string) { + if runtime.GOOS == "windows" { + return + } localGrpcSocketsLock.Lock() defer localGrpcSocketsLock.Unlock() localGrpcSockets[grpcPort] = socketPath diff --git a/weed/pb/grpc_client_server_test.go b/weed/pb/grpc_client_server_test.go index 210578d68..bdc3cc48b 100644 --- a/weed/pb/grpc_client_server_test.go +++ b/weed/pb/grpc_client_server_test.go @@ -2,6 +2,7 @@ package pb import ( "fmt" + "runtime" "testing" "google.golang.org/grpc/codes" @@ -74,6 +75,9 @@ func TestIsClientSideMarshalError_RequiresGrpcStatus(t *testing.T) { // continue out over TCP — they must NOT be hijacked into host A's local // socket on the basis of port match alone. func TestResolveLocalGrpcSocket_RemotePortCollision(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("Unix-socket routing is disabled on Windows (#9430)") + } // Snapshot and restore global state so the test does not leak into others. localGrpcSocketsLock.Lock() prevSockets := localGrpcSockets