diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2013-11-11 21:25:42 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2013-11-11 21:25:42 +0000 |
commit | 9544822809268ed981b10d31efd6225361ba537b (patch) | |
tree | a470cdd04f64276bd47a99e4dd2a6f25afeee4ae /libgo/go/net/tcpsockopt_solaris.go | |
parent | 3c450181dc21de5fac5e6d96600bbdd16cb7fdcb (diff) | |
download | gcc-9544822809268ed981b10d31efd6225361ba537b.zip gcc-9544822809268ed981b10d31efd6225361ba537b.tar.gz gcc-9544822809268ed981b10d31efd6225361ba537b.tar.bz2 |
net: Fix TCP keepalive handling for Solaris.
From-SVN: r204688
Diffstat (limited to 'libgo/go/net/tcpsockopt_solaris.go')
-rw-r--r-- | libgo/go/net/tcpsockopt_solaris.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/libgo/go/net/tcpsockopt_solaris.go b/libgo/go/net/tcpsockopt_solaris.go new file mode 100644 index 0000000..a285e2d --- /dev/null +++ b/libgo/go/net/tcpsockopt_solaris.go @@ -0,0 +1,25 @@ +// Copyright 2009 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. + +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 milliseconds so round to next highest millisecond. + d += (time.Millisecond - time.Nanosecond) + msecs := int(d.Nanoseconds() / time.Millisecond) + + return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(fd.sysfd, syscall.IPPROTO_TCP, syscall.TCP_KEEPALIVE_THRESHOLD, msecs)) +} |