Fix an issue with reusing closed network connetion, changing the way rateLimitedListener is initialized

master
Harshavardhana 10 years ago
parent dc11a411c7
commit 1f2e6a40a0
  1. 3
      pkg/server/minhttp/listen.go
  2. 14
      pkg/server/minhttp/net.go
  3. 2
      pkg/server/server.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 {
if nconn > 0 {
return &rateLimitListener{l, make(chan struct{}, nconn)}
}
return l
}
type rateLimitListener struct {

@ -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
}

@ -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,
}

Loading…
Cancel
Save