Properly bubble up setsockopt error from closure
This commit is contained in:
parent
8fde8334dc
commit
6e61c369e8
11
mark_unix.go
11
mark_unix.go
|
@ -26,6 +26,7 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bind *NativeBind) SetMark(mark uint32) error {
|
func (bind *NativeBind) SetMark(mark uint32) error {
|
||||||
|
var operr error
|
||||||
if fwmarkIoctl == 0 {
|
if fwmarkIoctl == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -35,8 +36,11 @@ func (bind *NativeBind) SetMark(mark uint32) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = fd.Control(func(fd uintptr) {
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -47,8 +51,11 @@ func (bind *NativeBind) SetMark(mark uint32) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = fd.Control(func(fd uintptr) {
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue