remove unused files
[platform/upstream/gcc48.git] / libgo / go / net / sock_linux.go
1 // Copyright 2009 The Go Authors.  All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package net
6
7 import "syscall"
8
9 func maxListenerBacklog() int {
10         fd, err := open("/proc/sys/net/core/somaxconn")
11         if err != nil {
12                 return syscall.SOMAXCONN
13         }
14         defer fd.close()
15         l, ok := fd.readLine()
16         if !ok {
17                 return syscall.SOMAXCONN
18         }
19         f := getFields(l)
20         n, _, ok := dtoi(f[0], 0)
21         if n == 0 || !ok {
22                 return syscall.SOMAXCONN
23         }
24         // Linux stores the backlog in a uint16.
25         // Truncate number to avoid wrapping.
26         // See issue 5030.
27         if n > 1<<16-1 {
28                 n = 1<<16 - 1
29         }
30         return n
31 }