add option for max connection (#112)

add option for max connection
This commit is contained in:
Yifa Zhang 2016-08-13 15:29:21 +08:00 committed by Iwasaki Yudai
parent 54597c0ba6
commit be07d420dd
4 changed files with 31 additions and 2 deletions

View file

@ -79,7 +79,14 @@ func (context *clientContext) goHandleClient() {
context.command.Wait()
context.connection.Close()
log.Printf("Connection closed: %s", context.request.RemoteAddr)
context.app.connections--
if context.app.options.MaxConnection != 0 {
log.Printf("Connection closed: %s, connections: %d/%d",
context.request.RemoteAddr, context.app.connections, context.app.options.MaxConnection)
} else {
log.Printf("Connection closed: %s, connections: %d",
context.request.RemoteAddr, context.app.connections)
}
}()
}