mirror of
https://github.com/tailscale/tailscale.git
synced 2026-11-24 02:31:18 -08:00
On macOS and iOS, UDP reads have been observed to fail with ENOTSOCK and EBADF. Both errors indicate that the fd is no longer usable. The receive function would retry reading from the bad socket until some other event, like a link change, caused a rebind. magicsock now rebinds when a read fails with EBADF or ENOTSOCK. Read and write failures share a single 5s throttle to handle bursts of failures. Updates #22097 Change-Id: Idd19f7094d9fc11e0f61a3207eb20281acfd5255 Signed-off-by: Nick Beirne <[email protected]>
30 lines
788 B
Go
30 lines
788 B
Go
// Copyright (c) Tailscale Inc & contributors
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
//go:build plan9
|
|
|
|
package neterror
|
|
|
|
import (
|
|
"errors"
|
|
"io"
|
|
"io/fs"
|
|
"strings"
|
|
)
|
|
|
|
// IsBadSocketError always returns false on Plan 9.
|
|
func IsBadSocketError(err error) bool {
|
|
return false
|
|
}
|
|
|
|
// Reports whether err resulted from reading or writing to a closed or broken pipe.
|
|
func IsClosedPipeError(err error) bool {
|
|
// Libraries may also return root errors like fs.ErrClosed/io.ErrClosedPipe
|
|
// due to a closed socket.
|
|
// For a raw syscall error, check for error string containing "closed pipe",
|
|
// per the note set by the system: https://9p.io/magic/man2html/2/pipe
|
|
return errors.Is(err, fs.ErrClosed) ||
|
|
errors.Is(err, io.ErrClosedPipe) ||
|
|
strings.Contains(err.Error(), "closed pipe")
|
|
}
|