On Fri, Jan 16, 2015 at 1:06 AM, Rainer Orth
<r...@cebitec.uni-bielefeld.de> wrote:
> Ian Lance Taylor <i...@golang.org> writes:
>
>> On Thu, Jan 15, 2015 at 8:30 AM, Rainer Orth
>> <r...@cebitec.uni-bielefeld.de> wrote:
>>>
>>> This (and perhaps the previous gotools) patch broke Solaris bootstrap:
>>>
>>> /vol/gcc/src/hg/trunk/local/libgo/go/net/tcpsockopt_unix.go:23:73: error:
>>> reference to undefined identifier 'syscall.TCP_KEEPINTVL'
>>>   if err := syscall.SetsockoptInt(fd.sysfd, syscall.IPPROTO_TCP,
>>> syscall.TCP_KEEPINTVL, secs); err != nil {
>>> /vol/gcc/src/hg/trunk/local/libgo/go/net/tcpsockopt_unix.go:26:103:
>>> error: reference to undefined identifier 'syscall.TCP_KEEPIDLE'
>>>   return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(fd.sysfd,
>>> syscall.IPPROTO_TCP, syscall.TCP_KEEPIDLE, secs))
>>> make[4]: *** [net.lo] Error 1
>>>
>>> The following patch fixes this:
>>
>> That's interesting--would you mind looking into this just a bit more?
>> What version of Solaris was this?  In the gc version of the library,
>> those symbols are defined for Solaris.  TCP_KEEPINTVL is 0x24 and
>> TCP_KEEPIDLE is 0x22.  I just want to make sure that they are really
>> not defined on your system, and the problem is not that mksysinfo is
>> somehow failing to handle the definition.
>
> I'd checked this before and did some more archaeology now: on Solaris
> 11.2, <netinet/tcp.h> has
>
> #define TCP_INFO                        0x22    /* connection information */
>
> and 0x24 isn't defined yet.
>
> OTOH, on Illumos (one of the OpenSolaris derivatives) I find
>
> #define TCP_KEEPIDLE                    0x22
> #define TCP_KEEPINTVL                   0x24

Thanks for looking into this.  In that case I think we should go back
to the earlier Solaris-specific version of setKeepAlivePeriod.  I've
committed this patch to mainline.

Ian
diff -r f398d4580f6b libgo/Makefile.am
--- a/libgo/Makefile.am Thu Jan 15 18:53:13 2015 -0800
+++ b/libgo/Makefile.am Fri Jan 16 07:53:22 2015 -0800
@@ -762,6 +762,9 @@
 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 @@
 endif
 endif
 endif
+endif
 
 go_net_files = \
        go/net/cgo_unix.go \
diff -r f398d4580f6b libgo/Makefile.in
--- a/libgo/Makefile.in Thu Jan 15 18:53:13 2015 -0800
+++ b/libgo/Makefile.in Fri Jan 16 07:53:22 2015 -0800
@@ -1019,8 +1019,9 @@
 @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 -r f398d4580f6b libgo/go/net/tcpsockopt_solaris.go
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/libgo/go/net/tcpsockopt_solaris.go        Fri Jan 16 07:53:22 2015 -0800
@@ -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))
+}

Reply via email to