server/mux: Close the connection even if buffer.Flush() returns error. (#3599)

It is possible that buf.Flush() might return an error, leading to a
potential leak in active sockets.
master
Harshavardhana 8 years ago committed by GitHub
parent 9e1f1b50e0
commit a17f1e875c
  1. 10
      cmd/server-mux.go

@ -108,10 +108,12 @@ func (c *ConnMux) Read(b []byte) (int, error) {
// Close the connection.
func (c *ConnMux) Close() (err error) {
if err = c.bufrw.Flush(); err != nil {
return err
}
return c.Conn.Close()
// Make sure that we always close a connection,
// even if the bufioWriter flush sends an error.
defer c.Conn.Close()
// Flush and write to the connection.
return c.bufrw.Flush()
}
// ListenerMux wraps the standard net.Listener to inspect

Loading…
Cancel
Save