From a6b8a5487a2f27cb6891bc64e74d168cb8b3a606 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 17 Aug 2018 21:06:36 -0700 Subject: [PATCH] Fail gateway properly with an error on port conflicts (#6303) --- cmd/gateway-main.go | 18 ++++++------------ cmd/http/listen_nix.go | 1 - 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/cmd/gateway-main.go b/cmd/gateway-main.go index 8dd66b17a..506658f9b 100644 --- a/cmd/gateway-main.go +++ b/cmd/gateway-main.go @@ -22,7 +22,6 @@ import ( "net/url" "os" "os/signal" - "runtime" "strings" "syscall" @@ -83,17 +82,6 @@ func ValidateGatewayArguments(serverAddr, endpointAddr string) error { return err } - if runtime.GOOS == "darwin" { - _, port := mustSplitHostPort(serverAddr) - // On macOS, if a process already listens on LOCALIPADDR:PORT, net.Listen() falls back - // to IPv6 address i.e minio will start listening on IPv6 address whereas another - // (non-)minio process is listening on IPv4 of given port. - // To avoid this error situation we check for port availability only for macOS. - if err := checkPortAvailability(port); err != nil { - return err - } - } - if endpointAddr != "" { // Reject the endpoint if it points to the gateway handler itself. sameTarget, err := sameLocalAddrs(endpointAddr, serverAddr) @@ -148,6 +136,12 @@ func StartGateway(ctx *cli.Context, gw Gateway) { // Handle common env vars. handleCommonEnvVars() + // On macOS, if a process already listens on LOCALIPADDR:PORT, net.Listen() falls back + // to IPv6 address ie minio will start listening on IPv6 address whereas another + // (non-)minio process is listening on IPv4 of given port. + // To avoid this error situation we check for port availability. + logger.FatalIf(checkPortAvailability(globalMinioPort), "Unable to start the server") + // Validate if we have access, secret set through environment. if !globalIsEnvCreds { logger.Fatal(uiErrEnvCredentialsMissingGateway(nil), "Unable to start gateway") diff --git a/cmd/http/listen_nix.go b/cmd/http/listen_nix.go index a522dc4bc..c6f6cb0da 100644 --- a/cmd/http/listen_nix.go +++ b/cmd/http/listen_nix.go @@ -21,7 +21,6 @@ package http import "github.com/valyala/tcplisten" var cfg = &tcplisten.Config{ - ReusePort: true, DeferAccept: true, FastOpen: true, }