diff options
Diffstat (limited to 'libgo/go/net/sockoptip_linux.go')
-rw-r--r-- | libgo/go/net/sockoptip_linux.go | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/libgo/go/net/sockoptip_linux.go b/libgo/go/net/sockoptip_linux.go index 360f8dea60a..169718f14aa 100644 --- a/libgo/go/net/sockoptip_linux.go +++ b/libgo/go/net/sockoptip_linux.go @@ -12,7 +12,9 @@ import ( ) func ipv4MulticastInterface(fd *netFD) (*Interface, error) { - fd.incref() + if err := fd.incref(false); err != nil { + return nil, err + } defer fd.decref() mreq, err := syscall.GetsockoptIPMreqn(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_IF) if err != nil { @@ -30,7 +32,9 @@ func setIPv4MulticastInterface(fd *netFD, ifi *Interface) error { v = int32(ifi.Index) } mreq := &syscall.IPMreqn{Ifindex: v} - fd.incref() + if err := fd.incref(false); err != nil { + return err + } defer fd.decref() err := syscall.SetsockoptIPMreqn(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_IF, mreq) if err != nil { @@ -40,7 +44,9 @@ func setIPv4MulticastInterface(fd *netFD, ifi *Interface) error { } func ipv4MulticastTTL(fd *netFD) (int, error) { - fd.incref() + if err := fd.incref(false); err != nil { + return 0, err + } defer fd.decref() v, err := syscall.GetsockoptInt(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_TTL) if err != nil { @@ -50,7 +56,9 @@ func ipv4MulticastTTL(fd *netFD) (int, error) { } func setIPv4MulticastTTL(fd *netFD, v int) error { - fd.incref() + if err := fd.incref(false); err != nil { + return err + } defer fd.decref() err := syscall.SetsockoptInt(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_TTL, v) if err != nil { @@ -60,7 +68,9 @@ func setIPv4MulticastTTL(fd *netFD, v int) error { } func ipv4MulticastLoopback(fd *netFD) (bool, error) { - fd.incref() + if err := fd.incref(false); err != nil { + return false, err + } defer fd.decref() v, err := syscall.GetsockoptInt(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_LOOP) if err != nil { @@ -70,7 +80,9 @@ func ipv4MulticastLoopback(fd *netFD) (bool, error) { } func setIPv4MulticastLoopback(fd *netFD, v bool) error { - fd.incref() + if err := fd.incref(false); err != nil { + return err + } defer fd.decref() err := syscall.SetsockoptInt(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_LOOP, boolint(v)) if err != nil { @@ -80,7 +92,9 @@ func setIPv4MulticastLoopback(fd *netFD, v bool) error { } func ipv4ReceiveInterface(fd *netFD) (bool, error) { - fd.incref() + if err := fd.incref(false); err != nil { + return false, err + } defer fd.decref() v, err := syscall.GetsockoptInt(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_PKTINFO) if err != nil { @@ -90,7 +104,9 @@ func ipv4ReceiveInterface(fd *netFD) (bool, error) { } func setIPv4ReceiveInterface(fd *netFD, v bool) error { - fd.incref() + if err := fd.incref(false); err != nil { + return err + } defer fd.decref() err := syscall.SetsockoptInt(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_PKTINFO, boolint(v)) if err != nil { @@ -100,17 +116,21 @@ func setIPv4ReceiveInterface(fd *netFD, v bool) error { } func ipv6TrafficClass(fd *netFD) (int, error) { - fd.incref() + if err := fd.incref(false); err != nil { + return 0, err + } defer fd.decref() v, err := syscall.GetsockoptInt(fd.sysfd, syscall.IPPROTO_IPV6, syscall.IPV6_TCLASS) if err != nil { - return -1, os.NewSyscallError("getsockopt", err) + return 0, os.NewSyscallError("getsockopt", err) } return v, nil } func setIPv6TrafficClass(fd *netFD, v int) error { - fd.incref() + if err := fd.incref(false); err != nil { + return err + } defer fd.decref() err := syscall.SetsockoptInt(fd.sysfd, syscall.IPPROTO_IPV6, syscall.IPV6_TCLASS, v) if err != nil { |