From 72d7151a721ce182f4a13e7e5a6f5ced2f468c17 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 16 Jan 2015 15:57:32 +0000 Subject: [PATCH] net: Restore earlier Solaris-specific version of setKeepAlivePeriod. 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 | 4 ++++ libgo/Makefile.in | 5 +++-- libgo/go/net/tcpsockopt_solaris.go | 27 +++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 libgo/go/net/tcpsockopt_solaris.go diff --git a/libgo/Makefile.am b/libgo/Makefile.am index 0ce357690a8..419598183ed 100644 --- a/libgo/Makefile.am +++ b/libgo/Makefile.am @@ -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 \ diff --git a/libgo/Makefile.in b/libgo/Makefile.in index 495dc350b70..af8566f6837 100644 --- a/libgo/Makefile.in +++ b/libgo/Makefile.in @@ -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 index 00000000000..eaab6b6787b --- /dev/null +++ b/libgo/go/net/tcpsockopt_solaris.go @@ -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)) +} -- 2.30.2