diff --git a/README.md b/README.md index 110d161d..0ee8b120 100644 --- a/README.md +++ b/README.md @@ -906,6 +906,7 @@ What a target lacks, rbgo leaves out the way MRI does: - **The store gems** — SQLite3, Sequel, ActiveRecord's adapter, Bolt, Bleve, Etcd and Confd — need modernc.org/sqlite, which has a port for darwin/{amd64,arm64}, freebsd/{386,amd64,arm,arm64}, linux/{386,amd64,arm,arm64,loong64,ppc64le,riscv64,s390x}, netbsd/amd64, openbsd/{amd64,arm64} and windows. Elsewhere (wasm included) `require` still works and the modules exist, and the first real operation raises `NotImplementedError: sqlite3 is not supported on linux/mips64le` (or the gem and target in question). - **Errno**: a name the system's `` lacks is still a constant, naming `Errno::NOERROR`, as MRI's `undefined_error` does: `EMULTIHOP` and `ENOLINK` on OpenBSD, `ENOTRECOVERABLE` and `EOWNERDEAD` on NetBSD and DragonFly. +- **Errno on Windows**: a failed call's Win32 or Winsock code picks its class through MRI's own table (`errmap` and `rb_w32_map_errno` in `win32/win32.c`), so a missing directory is `Errno::ENOENT` and a refused connection `Errno::ECONNREFUSED`, as under MRI; a Win32 code absent from the table is `Errno::EINVAL`. Eight Winsock rows (`ESHUTDOWN`, `ETOOMANYREFS`, `EHOSTDOWN`, `EPFNOSUPPORT`, `ESOCKTNOSUPPORT`, `EPROCLIM`, `EUSERS`, `EREMOTE`) name classes rbgo has no number for on any target, so those failures raise plain `SystemCallError` ([#980](https://github.com/go-embedded-ruby/ruby/issues/980)). - **`Process::RLIMIT_*`** exist only where the system has the resource: no `RLIMIT_AS` on OpenBSD, no `RLIMIT_MEMLOCK` on AIX, only `RLIMIT_AS` of the four optional ones on Solaris and illumos. - **`File#flock`** and PStore's lock use `flock(2)`; AIX has none, so there it is emulated with `fcntl(2)` record locks, exactly as MRI's `missing/flock.c` does. - **plan9 (386, amd64, arm) compiles and vets, and is untested at run time.** Its `syscall` package has no errno numbers (`syscall.EINVAL` is a string error there), no `Kill`, `Flock`, `Getrlimit`, `Umask` or `Stat_t`, so rbgo has a plan9 variant of each seam. Nothing has been run on a Plan 9 kernel; the one part with tests is the error-string mapping, which is pure Go and runs on every platform. What that means: diff --git a/internal/vm/errno_host.go b/internal/vm/errno_host.go index 326d5646..86629ce0 100644 --- a/internal/vm/errno_host.go +++ b/internal/vm/errno_host.go @@ -16,20 +16,37 @@ import ( // *os.SyscallError, *net.OpError …). ok is false for an error with no errno // behind it. The Plan 9 counterpart (errno_plan9.go) has no numbers to dig out and // derives one from the error string instead. +// +// The number is the one of the class MRI raises, which on Windows is not the +// code the call failed with: a Windows syscall.Errno is the Win32 code itself, +// and MRI maps it through rb_w32_map_errno before anything raises it, so +// ERROR_PATH_NOT_FOUND (3) is Errno::ENOENT. mapHostErrno does that mapping +// there and is the identity elsewhere. Doing it here, once, means no raiser can +// look a raw Win32 code up in errnoClasses (go-embedded-ruby/ruby#980). +// +// ⚠ Windows: Go defines syscall.ENOENT as ERROR_FILE_NOT_FOUND (2) and +// syscall.ENOTDIR as ERROR_PATH_NOT_FOUND (3), so an ENOTDIR that Go builds +// itself (os.MkdirAll through a file, os.ReadDir on one, filepath.EvalSymlinks) +// is the very number Windows uses for a missing path, and is mapped to ENOENT +// as MRI maps that code. No raiser here takes its error from those three +// today; one that does must decide the class itself. func errnoOfError(err error) (int64, bool) { var eno syscall.Errno if errors.As(err, &eno) { - return int64(eno), true + return mapHostErrno(int64(eno)), true } return 0, false } // errIsErrno reports whether err is the Errno class `name` (an errnoNumbers key): -// errors.Is against the host's syscall.Errno of that number, so it answers exactly -// what errors.Is(err, syscall.) would. It exists so the call sites compile -// on Plan 9, whose syscall package lacks most of those constants. +// whether errnoOfError maps it to that class's number. Off Windows that is +// errors.Is(err, syscall.) for the first errno in the chain; on Windows +// it also sees that ERROR_DIR_NOT_EMPTY is ENOTEMPTY, which errors.Is cannot. +// It exists so the call sites compile on Plan 9, whose syscall package lacks +// most of those constants. func errIsErrno(err error, name string) bool { - return errors.Is(err, syscall.Errno(errnoNumbers[name])) + eno, ok := errnoOfError(err) + return ok && eno == errnoNumbers[name] } // errnoText is the message sysFail embeds for an errno: errnoMessage of the host's diff --git a/internal/vm/errno_mapped_test.go b/internal/vm/errno_mapped_test.go new file mode 100644 index 00000000..587c624b --- /dev/null +++ b/internal/vm/errno_mapped_test.go @@ -0,0 +1,45 @@ +// Copyright (c) the go-embedded-ruby/ruby authors +// +// SPDX-License-Identifier: BSD-3-Clause + +package vm_test + +import "testing" + +// TestAFailedCallRaisesMRIsClassOnEveryHost (go-embedded-ruby/ruby#980): the +// expected output is MRI 4.0.7's on darwin, and MRI raises the same classes on +// Windows because it maps each Win32 code through errmap first. These are the +// rows where the raw Win32 code named another class, or none: +// +// - a path through a missing directory fails with ERROR_PATH_NOT_FOUND (3), +// which is Go's syscall.ENOTDIR on Windows, so it read as Errno::ENOTDIR; +// - rmdir of a non-empty directory fails with ERROR_DIR_NOT_EMPTY (145), +// which errors.Is never matched to ENOTEMPTY, so it fell to Errno::ENOENT. +// +// On the POSIX lanes these pass with or without the mapping; the Windows lane +// is the one that says whether it holds. +func TestAFailedCallRaisesMRIsClassOnEveryHost(t *testing.T) { + checkCases(t, []runCase{ + {`require "tmpdir" +Dir.mktmpdir do |d| + begin + Dir.chdir(File.join(d, "missing", "sub")) + rescue SystemCallError => e + p e.class + end + full = File.join(d, "full") + Dir.mkdir(full) + File.write(File.join(full, "f"), "x") + begin + Dir.rmdir(full) + rescue SystemCallError => e + p e.class + end + begin + File.truncate(File.join(d, "missing", "sub"), 0) + rescue SystemCallError => e + p e.class + end +end`, "Errno::ENOENT\nErrno::ENOTEMPTY\nErrno::ENOENT\n"}, + }) +} diff --git a/internal/vm/errno_win32_windows.go b/internal/vm/errno_win32_windows.go index c5cfa809..7341b2ab 100644 --- a/internal/vm/errno_win32_windows.go +++ b/internal/vm/errno_win32_windows.go @@ -20,9 +20,7 @@ import ( // // ERROR_INVALID_HANDLE appears twice in errmap, as EBADF and then EINVAL; the // first row is the one rb_w32_map_errno's loop returns, so it alone is here. -// The WSA rows are left out: their codes are at or above WSABASEERR, which -// mapHostErrno keeps as they are, as rb_w32_map_errno does for a WSA code -// absent from the table. +// The WSA rows are wsaErrnos. var win32Errnos = map[syscall.Errno]string{ windows.ERROR_INVALID_FUNCTION: "EINVAL", windows.ERROR_FILE_NOT_FOUND: "ENOENT", @@ -111,19 +109,102 @@ var win32Errnos = map[syscall.Errno]string{ windows.ERROR_CANT_RESOLVE_FILENAME: "ELOOP", } -// wsaBaseErr is WSABASEERR: from there up a code is a socket error, or one of -// the numbers Go invented for the POSIX names, and is kept as it is. +// wsaErrnos is the rest of MRI's errmap (win32/win32.c:235-277, v4.0.9): the +// Winsock rows, all 43 of them, in errmap's order. A socket call fails with +// one of these, so without them a refused connection is a bare +// SystemCallError where MRI raises Errno::ECONNREFUSED. +// +// Eight targets (EHOSTDOWN, EPFNOSUPPORT, EPROCLIM, EREMOTE, ESHUTDOWN, +// ESOCKTNOSUPPORT, ETOOMANYREFS, EUSERS) have no number in rbgo on any +// target (errnoUndefinedEverywhere), so no class to land in: mapHostErrno +// keeps the WSA code for them, which raises SystemCallError, until the +// per-platform errno tables define them. TestWSARowsWithoutAClass pins that +// list, so defining one shows up there. +var wsaErrnos = map[syscall.Errno]string{ + windows.WSAEINTR: "EINTR", + windows.WSAEBADF: "EBADF", + windows.WSAEACCES: "EACCES", + windows.WSAEFAULT: "EFAULT", + windows.WSAEINVAL: "EINVAL", + windows.WSAEMFILE: "EMFILE", + windows.WSAEWOULDBLOCK: "EWOULDBLOCK", + windows.WSAEINPROGRESS: "EINPROGRESS", + windows.WSAEALREADY: "EALREADY", + windows.WSAENOTSOCK: "ENOTSOCK", + windows.WSAEDESTADDRREQ: "EDESTADDRREQ", + windows.WSAEMSGSIZE: "EMSGSIZE", + windows.WSAEPROTOTYPE: "EPROTOTYPE", + windows.WSAENOPROTOOPT: "ENOPROTOOPT", + windows.WSAEPROTONOSUPPORT: "EPROTONOSUPPORT", + windows.WSAESOCKTNOSUPPORT: "ESOCKTNOSUPPORT", + windows.WSAEOPNOTSUPP: "EOPNOTSUPP", + windows.WSAEPFNOSUPPORT: "EPFNOSUPPORT", + windows.WSAEAFNOSUPPORT: "EAFNOSUPPORT", + windows.WSAEADDRINUSE: "EADDRINUSE", + windows.WSAEADDRNOTAVAIL: "EADDRNOTAVAIL", + windows.WSAENETDOWN: "ENETDOWN", + windows.WSAENETUNREACH: "ENETUNREACH", + windows.WSAENETRESET: "ENETRESET", + windows.WSAECONNABORTED: "ECONNABORTED", + windows.WSAECONNRESET: "ECONNRESET", + windows.WSAENOBUFS: "ENOBUFS", + windows.WSAEISCONN: "EISCONN", + windows.WSAENOTCONN: "ENOTCONN", + windows.WSAESHUTDOWN: "ESHUTDOWN", + windows.WSAETOOMANYREFS: "ETOOMANYREFS", + windows.WSAETIMEDOUT: "ETIMEDOUT", + windows.WSAECONNREFUSED: "ECONNREFUSED", + windows.WSAELOOP: "ELOOP", + windows.WSAENAMETOOLONG: "ENAMETOOLONG", + windows.WSAEHOSTDOWN: "EHOSTDOWN", + windows.WSAEHOSTUNREACH: "EHOSTUNREACH", + windows.WSAEPROCLIM: "EPROCLIM", + windows.WSAENOTEMPTY: "ENOTEMPTY", + windows.WSAEUSERS: "EUSERS", + windows.WSAEDQUOT: "EDQUOT", + windows.WSAESTALE: "ESTALE", + windows.WSAEREMOTE: "EREMOTE", +} + +// wsaBaseErr is WSABASEERR: from there up a code absent from errmap is a +// socket error MRI has no class for, or one of the numbers Go invented for the +// POSIX names, and is kept as it is. const wsaBaseErr = 10000 // mapHostErrno is rb_w32_map_errno: the errno number of the class MRI raises // for the Win32 code eno. A code in errmap gets its class; a code at or above -// WSABASEERR is kept; any other code is EINVAL. +// WSABASEERR is kept; any other code is EINVAL. A row whose class rbgo has no +// number for keeps the code too (see wsaErrnos). func mapHostErrno(eno int64) int64 { - if eno == 0 || eno >= wsaBaseErr { + if eno == 0 { + return 0 + } + name, ok := win32Errnos[syscall.Errno(eno)] + if !ok { + name, ok = wsaErrnos[syscall.Errno(eno)] + } + if ok { + if n, ok := errnoNumberOf(name); ok { + return n + } return eno } - if name, ok := win32Errnos[syscall.Errno(eno)]; ok { - return errnoNumbers[name] + if eno >= wsaBaseErr { + return eno } return errnoNumbers["EINVAL"] } + +// errnoNumberOf is the number of the Errno class `name` names on this target: +// its own, or the one an alias (EWOULDBLOCK) shares. ok is false for a name +// with no number here. +func errnoNumberOf(name string) (int64, bool) { + if n, ok := errnoNumbers[name]; ok { + return n, true + } + if a, ok := errnoAliases[name]; ok { + n, ok := errnoNumbers[a] + return n, ok + } + return 0, false +} diff --git a/internal/vm/errno_win32_windows_internal_test.go b/internal/vm/errno_win32_windows_internal_test.go index dc901881..6dd2e3c3 100644 --- a/internal/vm/errno_win32_windows_internal_test.go +++ b/internal/vm/errno_win32_windows_internal_test.go @@ -7,6 +7,7 @@ package vm import ( + "os" "syscall" "testing" @@ -35,6 +36,14 @@ func TestMapHostErrnoIsRbW32MapErrno(t *testing.T) { {windows.ERROR_INVALID_NAME, "EINVAL"}, // A number Go invented for a POSIX name: kept. {syscall.ENOENT, "ENOENT"}, + // The Winsock rows (go-embedded-ruby/ruby#980). + {windows.WSAECONNRESET, "ECONNRESET"}, + {windows.WSAECONNREFUSED, "ECONNREFUSED"}, + {windows.WSAENOTSOCK, "ENOTSOCK"}, + {windows.WSAEMSGSIZE, "EMSGSIZE"}, + {windows.WSAENOTEMPTY, "ENOTEMPTY"}, + // EWOULDBLOCK is a second name for EAGAIN's class in rbgo. + {windows.WSAEWOULDBLOCK, "EAGAIN"}, } for _, c := range cases { if got := mapHostErrno(int64(c.eno)); got != errnoNumbers[c.want] { @@ -44,7 +53,51 @@ func TestMapHostErrnoIsRbW32MapErrno(t *testing.T) { if got := mapHostErrno(0); got != 0 { t.Errorf("mapHostErrno(0) = %d, want 0", got) } - if got := mapHostErrno(int64(windows.WSAECONNRESET)); got != int64(windows.WSAECONNRESET) { - t.Errorf("a WSA code was changed to %d", got) + // A WSA code absent from errmap is kept, as rb_w32_map_errno keeps it. + if got := mapHostErrno(int64(windows.WSAEDISCON)); got != int64(windows.WSAEDISCON) { + t.Errorf("WSAEDISCON was changed to %d", got) + } +} + +// TestWSARowsWithoutAClass pins the errmap rows whose class rbgo has no number +// for: mapHostErrno keeps their WSA code. Defining one of those names on +// Windows moves it out of this list, and the test says which. +func TestWSARowsWithoutAClass(t *testing.T) { + want := map[string]bool{ + "EHOSTDOWN": true, "EPFNOSUPPORT": true, "EPROCLIM": true, "EREMOTE": true, + "ESHUTDOWN": true, "ESOCKTNOSUPPORT": true, "ETOOMANYREFS": true, "EUSERS": true, + } + if len(wsaErrnos) != 43 { + t.Errorf("wsaErrnos has %d rows; errmap has 43 Winsock rows", len(wsaErrnos)) + } + for code, name := range wsaErrnos { + got := mapHostErrno(int64(code)) + _, named := errnoNumberOf(name) + switch { + case want[name] && named: + t.Errorf("%s now has a number; drop it from this list", name) + case want[name] && got != int64(code): + t.Errorf("%d (%s, no class) was changed to %d", code, name, got) + case !want[name] && !named: + t.Errorf("%s has no number on Windows; WSA code %d keeps its own", name, code) + case !want[name] && got == int64(code): + t.Errorf("%d (%s) was not mapped", code, name) + } + } +} + +// TestErrnoOfErrorMapsTheWin32Code: the mapping is applied where the number +// is dug out, so every raiser sees MRI's class, not the raw code. +func TestErrnoOfErrorMapsTheWin32Code(t *testing.T) { + err := &os.PathError{Op: "open", Path: `C:\nope\x`, Err: windows.ERROR_PATH_NOT_FOUND} + if got, ok := errnoOfError(err); !ok || got != errnoNumbers["ENOENT"] { + t.Errorf("errnoOfError = %d, %v; want ENOENT (%d)", got, ok, errnoNumbers["ENOENT"]) + } + dir := &os.PathError{Op: "remove", Path: `C:\d`, Err: windows.ERROR_DIR_NOT_EMPTY} + if !errIsErrno(dir, "ENOTEMPTY") { + t.Errorf("ERROR_DIR_NOT_EMPTY is not ENOTEMPTY") + } + if errIsErrno(dir, "ENOENT") { + t.Errorf("ERROR_DIR_NOT_EMPTY is ENOENT") } } diff --git a/internal/vm/errno_winsock_other.go b/internal/vm/errno_winsock_other.go deleted file mode 100644 index 192084a7..00000000 --- a/internal/vm/errno_winsock_other.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) the go-embedded-ruby/ruby authors -// -// SPDX-License-Identifier: BSD-3-Clause - -//go:build !windows - -package vm - -import "syscall" - -// posixErrno is the identity everywhere but Windows: a POSIX platform's socket -// calls already fail with POSIX errno numbers, so there is nothing to -// translate. See errno_winsock_windows.go for what the Windows half does and -// why the split exists at all. -func posixErrno(e syscall.Errno) syscall.Errno { return e } diff --git a/internal/vm/errno_winsock_windows.go b/internal/vm/errno_winsock_windows.go deleted file mode 100644 index 4fd72393..00000000 --- a/internal/vm/errno_winsock_windows.go +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) the go-embedded-ruby/ruby authors -// -// SPDX-License-Identifier: BSD-3-Clause - -//go:build windows - -package vm - -import ( - "syscall" - - "golang.org/x/sys/windows" -) - -// posixErrno maps a Winsock error to the POSIX errno Ruby reports for it. -// -// Windows socket calls fail with WSAE* codes in the 10000 range, which -// errnoClasses does not name -- so a refused connection arrived as a bare -// SystemCallError where MRI raises Errno::ECONNREFUSED, and `rescue -// Errno::ECONNREFUSED`, the retry idiom this change is about, matched nothing -// on this platform. The windows CI lane found it; darwin and linux were green, -// which is the shape of a divergence that only one lane can see. -// -// MRI does the same translation in rb_w32_map_errno (win32/win32.c), which is -// why a Ruby program written against POSIX errno classes works unchanged there. -// -// The target is syscall's own constant, not a number: on Windows Go defines the -// POSIX errnos above APPLICATION_ERROR rather than at their Unix values, and -// errnoClasses is built from those same constants -- so mapping to the constant -// lands in the table, and errnoStrerror then reports Go's text for it -// ("connection refused", capitalised). Hardcoding 61 would miss on both counts. -// -// The names come from golang.org/x/sys/windows because syscall defines only -// four of them (WSAEACCES, WSAECONNABORTED, WSAECONNRESET, WSAENOPROTOOPT) -- -// found by cross-building, not by CI. x/sys is already a direct dependency of -// this package (filestat_unix.go, spawn_native.go use x/sys/unix). -// -// The table is the socket path only: each entry is a WSAE* code whose POSIX twin -// Ruby code actually rescues. A code not listed keeps its own number and reaches -// the SystemCallError arm, which is the honest answer for one with no POSIX -// meaning. -// -// ⚠ The CLASS is what this decides, and the windows lane asserts it. The MESSAGE -// is not measured against a Windows MRI anywhere here -- there is no Windows -// host on this machine -- so no test claims its exact bytes on this platform. -func posixErrno(e syscall.Errno) syscall.Errno { - if p, ok := winsockToPosix[e]; ok { - return p - } - return e -} - -var winsockToPosix = map[syscall.Errno]syscall.Errno{ - windows.WSAECONNREFUSED: syscall.ECONNREFUSED, - windows.WSAETIMEDOUT: syscall.ETIMEDOUT, - windows.WSAEHOSTUNREACH: syscall.EHOSTUNREACH, - windows.WSAENETUNREACH: syscall.ENETUNREACH, - windows.WSAENETDOWN: syscall.ENETDOWN, - windows.WSAEADDRINUSE: syscall.EADDRINUSE, - windows.WSAEADDRNOTAVAIL: syscall.EADDRNOTAVAIL, - windows.WSAENOTCONN: syscall.ENOTCONN, - windows.WSAEISCONN: syscall.EISCONN, - windows.WSAEINVAL: syscall.EINVAL, - windows.WSAEMFILE: syscall.EMFILE, - windows.WSAEINTR: syscall.EINTR, - syscall.WSAECONNRESET: syscall.ECONNRESET, - syscall.WSAECONNABORTED: syscall.ECONNABORTED, - syscall.WSAEACCES: syscall.EACCES, -} diff --git a/internal/vm/file.go b/internal/vm/file.go index 1f6241d6..b413e604 100644 --- a/internal/vm/file.go +++ b/internal/vm/file.go @@ -1,14 +1,12 @@ package vm import ( - "errors" "os" "os/user" "path" // always '/'-separated, as Ruby's File is — not path/filepath "path/filepath" // OS-native, only for symlink resolution (File.realpath) "sort" "strings" - "syscall" stdtime "time" "github.com/go-embedded-ruby/ruby/internal/object" @@ -583,7 +581,7 @@ func (vm *VM) registerFile() { if err := os.Truncate(p, intArg(args[1])); err != nil { // A negative (invalid) length is Errno::EINVAL; a missing path is // Errno::ENOENT — matching truncate(2) and MRI's rb_file_s_truncate. - if errors.Is(err, syscall.EINVAL) { + if errIsErrno(err, "EINVAL") { raise("Errno::EINVAL", "Invalid argument @ rb_file_s_truncate - %s", p) } raise("Errno::ENOENT", "No such file or directory @ rb_file_s_truncate - %s", p) diff --git a/internal/vm/io.go b/internal/vm/io.go index 957cb198..f1294163 100644 --- a/internal/vm/io.go +++ b/internal/vm/io.go @@ -8,7 +8,6 @@ import ( "os" "strconv" "strings" - "syscall" "time" "unicode/utf8" @@ -1166,7 +1165,7 @@ func raiseFlockErrno(err error, p string) { switch { case errIsErrno(err, "EBADF"): raise("Errno::EBADF", "Bad file descriptor @ rb_file_flock - %s", p) - case errors.Is(err, syscall.EINVAL): + case errIsErrno(err, "EINVAL"): raise("Errno::EINVAL", "Invalid argument @ rb_file_flock - %s", p) } raise("Errno::ENOTSUP", "Operation not supported @ rb_file_flock - %s", p) diff --git a/internal/vm/io_dirty.go b/internal/vm/io_dirty.go index d8f79a28..8317f210 100644 --- a/internal/vm/io_dirty.go +++ b/internal/vm/io_dirty.go @@ -107,10 +107,9 @@ func (o *IOObj) writeDirty(content []byte) error { // raiseFlushErr raises a failed flush as MRI's rb_io_flush_raw does, through // rb_sys_fail_on_write: the errno the system answered, not one guessed from // the path. ENOSPC from a full disk, EISDIR, EROFS all keep their class. On -// Windows the Win32 code is first mapped as rb_w32_map_errno does. +// Windows errnoOfError has mapped the Win32 code as rb_w32_map_errno does. func raiseFlushErr(err error, path string) { if eno, ok := errnoOfError(err); ok { - eno = mapHostErrno(eno) if name, ok := errnoClasses[eno]; ok { raise("Errno::"+name, "%s @ rb_io_flush_raw - %s", errnoStrerror(eno), path) } diff --git a/internal/vm/socket_dialerr.go b/internal/vm/socket_dialerr.go index 50a7c097..353602e6 100644 --- a/internal/vm/socket_dialerr.go +++ b/internal/vm/socket_dialerr.go @@ -7,7 +7,6 @@ package vm import ( "errors" "net" - "syscall" ) // raiseDialErr reports a failed connect the way MRI's socket layer does, which @@ -46,12 +45,9 @@ func raiseDialErr(err error, addr string) { } if eno, ok := errnoOfError(err); ok { // Windows fails socket calls with WSAE* codes in the 10000 range, which - // errnoClasses does not name -- so a refused connection arrived as a bare - // SystemCallError there while darwin and linux were green, and `rescue - // Errno::ECONNREFUSED` matched nothing on the one platform nobody tested - // it on. MRI translates the same way (rb_w32_map_errno); posixErrno is - // the identity everywhere else. - eno = int64(posixErrno(syscall.Errno(eno))) + // errnoClasses does not name; errnoOfError has already mapped them as + // rb_w32_map_errno does, so `rescue Errno::ECONNREFUSED` matches there. + // // An empty addr means the caller has no single peer to name -- the // Net::HTTP transport, where the phase may be a read rather than a // connect and Go's own text already carries the address. Naming