net: Restore earlier Solaris-specific version of setKeepAlivePeriod.
authorIan Lance Taylor <ian@gcc.gnu.org>
Fri, 16 Jan 2015 15:57:32 +0000 (15:57 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Fri, 16 Jan 2015 15:57:32 +0000 (15:57 +0000)
The version from the master repository seems to be appropriate
for OpenSolaris but not for Solaris itself.  Solaris 11.2
proper does not define TCP_KEEPIDLE or TCP_KEEPINTVL.

From-SVN: r219749

libgo/Makefile.am
libgo/Makefile.in
libgo/go/net/tcpsockopt_solaris.go [new file with mode: 0644]

index 0ce357690a836068cb6345ffd0e16ee3746f15e0..419598183ed30da2208e0e3951bf1668088457af 100644 (file)
@@ -762,6 +762,9 @@ else
 if LIBGO_IS_DARWIN
 go_net_tcpsockopt_file = go/net/tcpsockopt_darwin.go
 else
+if LIBGO_IS_SOLARIS
+go_net_tcpsockopt_file = go/net/tcpsockopt_solaris.go
+else
 if LIBGO_IS_DRAGONFLY
 go_net_tcpsockopt_file = go/net/tcpsockopt_dragonfly.go
 else
@@ -769,6 +772,7 @@ go_net_tcpsockopt_file = go/net/tcpsockopt_unix.go
 endif
 endif
 endif
+endif
 
 go_net_files = \
        go/net/cgo_unix.go \
index 495dc350b700e1fe11bcd977236dd3eb627ff949..af8566f683706c3b2672e881b6830599ab8cc07e 100644 (file)
@@ -1019,8 +1019,9 @@ go_mime_files = \
 @LIBGO_IS_LINUX_TRUE@go_net_interface_file = go/net/interface_linux.go
 @LIBGO_IS_LINUX_FALSE@go_net_cloexec_file = go/net/sys_cloexec.go
 @LIBGO_IS_LINUX_TRUE@go_net_cloexec_file = go/net/sock_cloexec.go
-@LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_DRAGONFLY_FALSE@@LIBGO_IS_OPENBSD_FALSE@go_net_tcpsockopt_file = go/net/tcpsockopt_unix.go
-@LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_DRAGONFLY_TRUE@@LIBGO_IS_OPENBSD_FALSE@go_net_tcpsockopt_file = go/net/tcpsockopt_dragonfly.go
+@LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_DRAGONFLY_FALSE@@LIBGO_IS_OPENBSD_FALSE@@LIBGO_IS_SOLARIS_FALSE@go_net_tcpsockopt_file = go/net/tcpsockopt_unix.go
+@LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_DRAGONFLY_TRUE@@LIBGO_IS_OPENBSD_FALSE@@LIBGO_IS_SOLARIS_FALSE@go_net_tcpsockopt_file = go/net/tcpsockopt_dragonfly.go
+@LIBGO_IS_DARWIN_FALSE@@LIBGO_IS_OPENBSD_FALSE@@LIBGO_IS_SOLARIS_TRUE@go_net_tcpsockopt_file = go/net/tcpsockopt_solaris.go
 @LIBGO_IS_DARWIN_TRUE@@LIBGO_IS_OPENBSD_FALSE@go_net_tcpsockopt_file = go/net/tcpsockopt_darwin.go
 @LIBGO_IS_OPENBSD_TRUE@go_net_tcpsockopt_file = go/net/tcpsockopt_openbsd.go
 go_net_files = \
diff --git a/libgo/go/net/tcpsockopt_solaris.go b/libgo/go/net/tcpsockopt_solaris.go
new file mode 100644 (file)
index 0000000..eaab6b6
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// TCP socket options for solaris
+
+package net
+
+import (
+       "os"
+       "syscall"
+       "time"
+)
+
+// Set keep alive period.
+func setKeepAlivePeriod(fd *netFD, d time.Duration) error {
+       if err := fd.incref(); err != nil {
+               return err
+       }
+       defer fd.decref()
+
+       // The kernel expects seconds so round to next highest second.
+       d += (time.Second - time.Nanosecond)
+       secs := int(d.Seconds())
+
+       return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(fd.sysfd, syscall.IPPROTO_TCP, syscall.SO_KEEPALIVE, secs))
+}