Update
This commit is contained in:
1 parent
3530afb854
commit
6903fcff27
2146 files changed
+112256
-190703
No files matched your search
+32
@@ -0,0 +1,32 @@
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build !plan9 && !js && !wasip1 && !wasm
|
||||
|
||||
package neterror
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"io/fs"
|
||||
"runtime"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// Reports whether err resulted from reading or writing to a closed or broken pipe.
|
||||
func IsClosedPipeError(err error) bool {
|
||||
// 232 is Windows error code ERROR_NO_DATA, "The pipe is being closed".
|
||||
if runtime.GOOS == "windows" && errors.Is(err, syscall.Errno(232)) {
|
||||
return true
|
||||
}
|
||||
|
||||
// EPIPE/ENOTCONN are common errors when a send fails due to a closed
|
||||
// socket. There is some platform and version inconsistency in which
|
||||
// error is returned, but the meaning is the same.
|
||||
// Libraries may also return root errors like fs.ErrClosed/io.ErrClosedPipe
|
||||
// due to a closed socket.
|
||||
return errors.Is(err, syscall.EPIPE) ||
|
||||
errors.Is(err, syscall.ENOTCONN) ||
|
||||
errors.Is(err, fs.ErrClosed) ||
|
||||
errors.Is(err, io.ErrClosedPipe)
|
||||
}
|
||||
Reference in new issue
Block a user