Browse Source

fix error formatting in sockopt

世界 3 years ago
parent
commit
093a4d6a82
2 changed files with 12 additions and 12 deletions
  1. 6 6
      transport/internet/sockopt_darwin.go
  2. 6 6
      transport/internet/sockopt_freebsd.go

+ 6 - 6
transport/internet/sockopt_darwin.go

@@ -26,18 +26,18 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
 
 
 		if config.TcpKeepAliveIdle > 0 {
 		if config.TcpKeepAliveIdle > 0 {
 			if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_KEEPALIVE, int(config.TcpKeepAliveInterval)); err != nil {
 			if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_KEEPALIVE, int(config.TcpKeepAliveInterval)); err != nil {
-				return newError("failed to set TCP_KEEPINTVL", err)
+				return newError("failed to set TCP_KEEPINTVL").Base(err)
 			}
 			}
 		}
 		}
 		if config.TcpKeepAliveInterval > 0 {
 		if config.TcpKeepAliveInterval > 0 {
 			if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_KEEPINTVL, int(config.TcpKeepAliveIdle)); err != nil {
 			if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_KEEPINTVL, int(config.TcpKeepAliveIdle)); err != nil {
-				return newError("failed to set TCP_KEEPIDLE", err)
+				return newError("failed to set TCP_KEEPIDLE").Base(err)
 			}
 			}
 		}
 		}
 
 
 		if config.TcpKeepAliveIdle > 0 || config.TcpKeepAliveInterval > 0 {
 		if config.TcpKeepAliveIdle > 0 || config.TcpKeepAliveInterval > 0 {
 			if err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_KEEPALIVE, 1); err != nil {
 			if err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_KEEPALIVE, 1); err != nil {
-				return newError("failed to set SO_KEEPALIVE", err)
+				return newError("failed to set SO_KEEPALIVE").Base(err)
 			}
 			}
 		}
 		}
 	}
 	}
@@ -59,17 +59,17 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig)
 		}
 		}
 		if config.TcpKeepAliveIdle > 0 {
 		if config.TcpKeepAliveIdle > 0 {
 			if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_KEEPALIVE, int(config.TcpKeepAliveInterval)); err != nil {
 			if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_KEEPALIVE, int(config.TcpKeepAliveInterval)); err != nil {
-				return newError("failed to set TCP_KEEPINTVL", err)
+				return newError("failed to set TCP_KEEPINTVL").Base(err)
 			}
 			}
 		}
 		}
 		if config.TcpKeepAliveInterval > 0 {
 		if config.TcpKeepAliveInterval > 0 {
 			if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.SO_KEEPALIVE, int(config.TcpKeepAliveIdle)); err != nil {
 			if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.SO_KEEPALIVE, int(config.TcpKeepAliveIdle)); err != nil {
-				return newError("failed to set TCP_KEEPIDLE", err)
+				return newError("failed to set TCP_KEEPIDLE").Base(err)
 			}
 			}
 		}
 		}
 		if config.TcpKeepAliveIdle > 0 || config.TcpKeepAliveInterval > 0 {
 		if config.TcpKeepAliveIdle > 0 || config.TcpKeepAliveInterval > 0 {
 			if err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_KEEPALIVE, 1); err != nil {
 			if err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_KEEPALIVE, 1); err != nil {
-				return newError("failed to set SO_KEEPALIVE", err)
+				return newError("failed to set SO_KEEPALIVE").Base(err)
 			}
 			}
 		}
 		}
 	}
 	}

+ 6 - 6
transport/internet/sockopt_freebsd.go

@@ -144,16 +144,16 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
 		if config.TcpKeepAliveIdle > 0 || config.TcpKeepAliveInterval > 0 {
 		if config.TcpKeepAliveIdle > 0 || config.TcpKeepAliveInterval > 0 {
 			if config.TcpKeepAliveIdle > 0 {
 			if config.TcpKeepAliveIdle > 0 {
 				if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_KEEPIDLE, int(config.TcpKeepAliveIdle)); err != nil {
 				if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_KEEPIDLE, int(config.TcpKeepAliveIdle)); err != nil {
-					return newError("failed to set TCP_KEEPIDLE", err)
+					return newError("failed to set TCP_KEEPIDLE").Base(err)
 				}
 				}
 			}
 			}
 			if config.TcpKeepAliveInterval > 0 {
 			if config.TcpKeepAliveInterval > 0 {
 				if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_KEEPINTVL, int(config.TcpKeepAliveInterval)); err != nil {
 				if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_KEEPINTVL, int(config.TcpKeepAliveInterval)); err != nil {
-					return newError("failed to set TCP_KEEPINTVL", err)
+					return newError("failed to set TCP_KEEPINTVL").Base(err)
 				}
 				}
 			}
 			}
 			if err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_KEEPALIVE, 1); err != nil {
 			if err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_KEEPALIVE, 1); err != nil {
-				return newError("failed to set SO_KEEPALIVE", err)
+				return newError("failed to set SO_KEEPALIVE").Base(err)
 			}
 			}
 		}
 		}
 	}
 	}
@@ -193,16 +193,16 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig)
 		if config.TcpKeepAliveIdle > 0 || config.TcpKeepAliveInterval > 0 {
 		if config.TcpKeepAliveIdle > 0 || config.TcpKeepAliveInterval > 0 {
 			if config.TcpKeepAliveIdle > 0 {
 			if config.TcpKeepAliveIdle > 0 {
 				if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_KEEPIDLE, int(config.TcpKeepAliveIdle)); err != nil {
 				if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_KEEPIDLE, int(config.TcpKeepAliveIdle)); err != nil {
-					return newError("failed to set TCP_KEEPIDLE", err)
+					return newError("failed to set TCP_KEEPIDLE").Base(err)
 				}
 				}
 			}
 			}
 			if config.TcpKeepAliveInterval > 0 {
 			if config.TcpKeepAliveInterval > 0 {
 				if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_KEEPINTVL, int(config.TcpKeepAliveInterval)); err != nil {
 				if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_KEEPINTVL, int(config.TcpKeepAliveInterval)); err != nil {
-					return newError("failed to set TCP_KEEPINTVL", err)
+					return newError("failed to set TCP_KEEPINTVL").Base(err)
 				}
 				}
 			}
 			}
 			if err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_KEEPALIVE, 1); err != nil {
 			if err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_KEEPALIVE, 1); err != nil {
-				return newError("failed to set SO_KEEPALIVE", err)
+				return newError("failed to set SO_KEEPALIVE").Base(err)
 			}
 			}
 		}
 		}
 	}
 	}