Add constant for tcp keepalive periode

Signed-off-by: Jan Fajerski <jfajerski@suse.com>
This commit is contained in:
Jan Fajerski 2018-07-09 11:08:14 +02:00
parent cd9aa031a8
commit a42a258a28

View File

@ -35,6 +35,8 @@ import (
// specifically check if it hits EMFILE when doing an accept, and if so,
// terminate the process.
const keepAlive time.Duration = 3 * time.Minute
type emfileAwareTcpListener struct {
*net.TCPListener
}
@ -52,7 +54,7 @@ func (ln emfileAwareTcpListener) Accept() (c net.Conn, err error) {
return
}
tc.SetKeepAlive(true)
tc.SetKeepAlivePeriod(3 * time.Minute)
tc.SetKeepAlivePeriod(keepAlive)
return tc, nil
}