Fail gateway properly with an error on port conflicts (#6303)

This commit is contained in:
Harshavardhana 2018-08-17 21:06:36 -07:00 committed by kannappanr
parent 6c0d53a1c5
commit a6b8a5487a
2 changed files with 6 additions and 13 deletions

View File

@ -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")

View File

@ -21,7 +21,6 @@ package http
import "github.com/valyala/tcplisten"
var cfg = &tcplisten.Config{
ReusePort: true,
DeferAccept: true,
FastOpen: true,
}