summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-12-25 22:56:36 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2018-12-25 22:56:36 +0100
commit6e61c369e8bf934688aeadae86f04fe25566320a (patch)
tree66c2bdac1a36820256cfbd9c50943fffd0eb33e4
parent8fde8334dcf3a7f3934159f45b6fc1d5f4be8a90 (diff)
Properly bubble up setsockopt error from closure
-rw-r--r--mark_unix.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/mark_unix.go b/mark_unix.go
index 0b9d7e0..f2b6f62 100644
--- a/mark_unix.go
+++ b/mark_unix.go
@@ -26,6 +26,7 @@ func init() {
}
func (bind *NativeBind) SetMark(mark uint32) error {
+ var operr error
if fwmarkIoctl == 0 {
return nil
}
@@ -35,8 +36,11 @@ func (bind *NativeBind) SetMark(mark uint32) error {
return err
}
err = fd.Control(func(fd uintptr) {
- err = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, fwmarkIoctl, int(mark))
+ operr = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, fwmarkIoctl, int(mark))
})
+ if err == nil {
+ err = operr
+ }
if err != nil {
return err
}
@@ -47,8 +51,11 @@ func (bind *NativeBind) SetMark(mark uint32) error {
return err
}
err = fd.Control(func(fd uintptr) {
- err = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, fwmarkIoctl, int(mark))
+ operr = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, fwmarkIoctl, int(mark))
})
+ if err == nil {
+ err = operr
+ }
if err != nil {
return err
}