Merge pull request #760 from harshavardhana/pr_out_fix_an_issue_with_reusing_closed_network_connetion_changing_the_way_ratelimitedlistener_is_initialized

Fix an issue with reusing closed network connetion, changing the way rateLimitedListener is initialized
master
Harshavardhana 9 years ago
commit 245ea26395
  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 // rateLimitedListener returns a Listener that accepts at most n simultaneous
// connections from the provided Listener. // connections from the provided Listener.
func rateLimitedListener(l net.Listener, nconn int) net.Listener { func rateLimitedListener(l net.Listener, nconn int) net.Listener {
if nconn > 0 {
return &rateLimitListener{l, make(chan struct{}, nconn)} return &rateLimitListener{l, make(chan struct{}, nconn)}
}
return l
} }
type rateLimitListener struct { type rateLimitListener struct {

@ -92,11 +92,11 @@ func (n *minNet) getInheritedListeners() error {
l, err := net.FileListener(file) l, err := net.FileListener(file)
if err != nil { if err != nil {
file.Close() 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 return
} }
if err := file.Close(); err != nil { 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 return
} }
n.inheritedListeners = append(n.inheritedListeners, l) 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 { if err != nil {
return nil, iodine.New(err, nil) return nil, iodine.New(err, nil)
} }
if n.connLimit > 0 { n.activeListeners = append(n.activeListeners, rateLimitedListener(l, n.connLimit))
l = rateLimitedListener(l, n.connLimit)
}
n.activeListeners = append(n.activeListeners, l)
return l, nil return l, nil
} }
@ -197,10 +194,7 @@ func (n *minNet) ListenUnix(nett string, laddr *net.UnixAddr) (net.Listener, err
if err != nil { if err != nil {
return nil, iodine.New(err, nil) return nil, iodine.New(err, nil)
} }
if n.connLimit > 0 { n.activeListeners = append(n.activeListeners, rateLimitedListener(l, n.connLimit))
l = rateLimitedListener(l, n.connLimit)
}
n.activeListeners = append(n.activeListeners, l)
return l, nil 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 { func getRPCServer(rpcHandler http.Handler) *http.Server {
// Minio server config // Minio server config
httpServer := &http.Server{ httpServer := &http.Server{
Addr: "127.0.0.1:9001", // TODO make this configurable Addr: ":9001", // TODO make this configurable
Handler: rpcHandler, Handler: rpcHandler,
MaxHeaderBytes: 1 << 20, MaxHeaderBytes: 1 << 20,
} }

Loading…
Cancel
Save