Skip to content

use if net.OpError.Err == syscall.EIPE, but net.OpError.Err never eq to syscall.EPIPE #110

@xiaotushaoxia

Description

@xiaotushaoxia
	broker := func(to, from *net.TCPConn) {
		written, err := io.Copy(to, from)
		if err != nil {
			// If the socket we are writing to is shutdown with
			// SHUT_WR, forward it to the other end of the pipe:
			if err, 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)
		if err != nil {
			// If the socket we are writing to is shutdown with
			// SHUT_WR, forward it to the other end of the pipe:
			var errno syscall.Errno
			if errors.As(err, &errno) && errno == syscall.EPIPE {
				_ = from.CloseRead()
			}
		}
		_ = to.CloseWrite()
		event <- written
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions