Merge pull request #6164 from benbjohnson/mux-timeout

Use timer for mux timeout
pull/6160/head
Ben Johnson 2016-03-30 15:58:11 -06:00
commit fb6a54fe05
1 changed files with 4 additions and 1 deletions

View File

@ -103,9 +103,12 @@ func (mux *Mux) handleConn(conn net.Conn) {
}
// Send connection to handler. The handler is responsible for closing the connection.
timer := time.NewTimer(mux.Timeout)
defer timer.Stop()
select {
case handler.c <- conn:
case <-time.After(mux.Timeout):
case <-timer.C:
conn.Close()
mux.Logger.Printf("tcp.Mux: handler not ready: %d. Connection from %s closed", typ[0], conn.RemoteAddr())
return