[server] If running in a chroot without /proc support, directly use tcplisten.

This commit is contained in:
Ciprian Dorin Craciun 2022-09-07 10:09:50 +03:00
parent c35f156e08
commit fe82980b7a

View file

@ -5,6 +5,7 @@ package server
import "runtime" import "runtime"
import "net" import "net"
import "os"
import "github.com/valyala/tcplisten" import "github.com/valyala/tcplisten"
@ -15,7 +16,20 @@ import "github.com/valyala/fasthttp/reuseport"
func listenTcp (_endpoint string) (net.Listener, error) { func listenTcp (_endpoint string) (net.Listener, error) {
if runtime.GOOS == "android" { _useTcpListen := false
if ! _useTcpListen {
if (runtime.GOOS == "android") {
_useTcpListen = true
}
}
if ! _useTcpListen {
if _, _error := os.Stat ("/proc/sys/net/core/somaxconn"); _error != nil {
_useTcpListen = true
}
}
if _useTcpListen {
var _config = & tcplisten.Config { var _config = & tcplisten.Config {
ReusePort : true, ReusePort : true,
DeferAccept : true, DeferAccept : true,