[server] If running in a chroot
without /proc
support, directly use tcplisten
.
This commit is contained in:
parent
c35f156e08
commit
fe82980b7a
1 changed files with 15 additions and 1 deletions
|
@ -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,
|
||||||
|
|
Loading…
Reference in a new issue