You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
broker:=func(to, from*net.TCPConn) {
written, err:=io.Copy(to, from)
iferr!=nil {
// If the socket we are writing to is shutdown with// SHUT_WR, forward it to the other end of the pipe:iferr, ok:=err.(*net.OpError); ok&&err.Err==syscall.EPIPE {
_=from.CloseRead()
}
}
_=to.CloseWrite()
event<-written
}
net.OpError.Err is *os.SyscallError, os.SyscallError.Err can not be syscall.Errno
maybe this is expected behavior
broker:=func(to, from*net.TCPConn) {
written, err:=io.Copy(to, from)
iferr!=nil {
// If the socket we are writing to is shutdown with// SHUT_WR, forward it to the other end of the pipe:varerrno syscall.Errnoiferrors.As(err, &errno) &&errno==syscall.EPIPE {
_=from.CloseRead()
}
}
_=to.CloseWrite()
event<-written
}
The text was updated successfully, but these errors were encountered:
xiaotushaoxia
changed the title
use if net.OpError.Err == syscall.EIPE, but net.OpError.Err never eq to syscall.EIPE
use if net.OpError.Err == syscall.EIPE, but net.OpError.Err never eq to syscall.EPIPE
Dec 20, 2023
Thanks for reporting; I was actually just looking at that code, and also considering to use errors.As; perhaps even just errors.Is(err, sys call.EPIPE) would do the trick, because net.OpError (and other errors) would be unwrapped by errors.Is 🤔
Let me open a draft PR for discussions; I'm also wondering if there's other errors that should be handled to detect things being closed.
net.OpError.Err is *os.SyscallError, os.SyscallError.Err can not be syscall.Errno
maybe this is expected behavior
The text was updated successfully, but these errors were encountered: