diff --git a/pkg/server/minhttp/listen.go b/pkg/server/minhttp/listen.go index 5792f95e1..08f649bc6 100644 --- a/pkg/server/minhttp/listen.go +++ b/pkg/server/minhttp/listen.go @@ -27,7 +27,10 @@ import ( // rateLimitedListener returns a Listener that accepts at most n simultaneous // connections from the provided Listener. func rateLimitedListener(l net.Listener, nconn int) net.Listener { - return &rateLimitListener{l, make(chan struct{}, nconn)} + if nconn > 0 { + return &rateLimitListener{l, make(chan struct{}, nconn)} + } + return l } type rateLimitListener struct { diff --git a/pkg/server/minhttp/net.go b/pkg/server/minhttp/net.go index 550d9ffe6..7e954d8af 100644 --- a/pkg/server/minhttp/net.go +++ b/pkg/server/minhttp/net.go @@ -92,11 +92,11 @@ func (n *minNet) getInheritedListeners() error { l, err := net.FileListener(file) if err != nil { file.Close() - retErr = fmt.Errorf("error inheriting socket fd %d: %s", i, err) + retErr = iodine.New(fmt.Errorf("error inheriting socket fd %d: %s", i, err), nil) return } if err := file.Close(); err != nil { - retErr = fmt.Errorf("error closing inherited socket fd %d: %s", i, err) + retErr = iodine.New(fmt.Errorf("error closing inherited socket fd %d: %s", i, err), nil) return } n.inheritedListeners = append(n.inheritedListeners, l) @@ -159,10 +159,7 @@ func (n *minNet) ListenTCP(nett string, laddr *net.TCPAddr) (net.Listener, error if err != nil { return nil, iodine.New(err, nil) } - if n.connLimit > 0 { - l = rateLimitedListener(l, n.connLimit) - } - n.activeListeners = append(n.activeListeners, l) + n.activeListeners = append(n.activeListeners, rateLimitedListener(l, n.connLimit)) return l, nil } @@ -197,10 +194,7 @@ func (n *minNet) ListenUnix(nett string, laddr *net.UnixAddr) (net.Listener, err if err != nil { return nil, iodine.New(err, nil) } - if n.connLimit > 0 { - l = rateLimitedListener(l, n.connLimit) - } - n.activeListeners = append(n.activeListeners, l) + n.activeListeners = append(n.activeListeners, rateLimitedListener(l, n.connLimit)) return l, nil } diff --git a/pkg/server/server.go b/pkg/server/server.go index 65a3943d6..9e643a074 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -87,7 +87,7 @@ func getAPIServer(conf api.Config, apiHandler http.Handler) (*http.Server, error func getRPCServer(rpcHandler http.Handler) *http.Server { // Minio server config httpServer := &http.Server{ - Addr: "127.0.0.1:9001", // TODO make this configurable + Addr: ":9001", // TODO make this configurable Handler: rpcHandler, MaxHeaderBytes: 1 << 20, }