diff mbox

Recent Go patch broke Solaris bootstrap

Message ID CAKOQZ8ya7UfDtn9iWwAS7QoUiBr+v5v7VcPThpP9vyPq225skw@mail.gmail.com
State New
Headers show

Commit Message

Ian Lance Taylor Nov. 11, 2013, 9:25 p.m. UTC
On Fri, Nov 8, 2013 at 4:01 AM, Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote:
> The recent Go patch (couldn't find the submission on gcc-patches) broke
> Solaris bootstrap: on Solaris 10/x86 I get
>
> /vol/gcc/src/hg/trunk/local/libgo/go/net/tcpsockopt_unix.go:26:103: error: reference to undefined identifier 'syscall.TCP_KEEPINTVL'
>   err := os.NewSyscallError("setsockopt", syscall.SetsockoptInt(fd.sysfd, syscall.IPPROTO_TCP, syscall.TCP_KEEPINTVL, secs))
>                                                                                                        ^
> /vol/gcc/src/hg/trunk/local/libgo/go/net/tcpsockopt_unix.go:30:103: error: reference to undefined identifier 'syscall.TCP_KEEPIDLE'
>   return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(fd.sysfd, syscall.IPPROTO_TCP, syscall.TCP_KEEPIDLE, secs))
>                                                                                                        ^

I think this will be fixed by the appended patch.  Bootstrapped and
tested on x86_64-unknown-linux-gnu, not that that proves anything.
Committed to mainline.

Ian

Comments

Rainer Orth Nov. 12, 2013, 2:43 p.m. UTC | #1
Ian Lance Taylor <iant@google.com> writes:

> On Fri, Nov 8, 2013 at 4:01 AM, Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote:
>> The recent Go patch (couldn't find the submission on gcc-patches) broke
>> Solaris bootstrap: on Solaris 10/x86 I get
>>
>> /vol/gcc/src/hg/trunk/local/libgo/go/net/tcpsockopt_unix.go:26:103: error: reference to undefined identifier 'syscall.TCP_KEEPINTVL'
>>   err := os.NewSyscallError("setsockopt", syscall.SetsockoptInt(fd.sysfd, syscall.IPPROTO_TCP, syscall.TCP_KEEPINTVL, secs))
>>                                                                                                        ^
>> /vol/gcc/src/hg/trunk/local/libgo/go/net/tcpsockopt_unix.go:30:103: error: reference to undefined identifier 'syscall.TCP_KEEPIDLE'
>>   return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(fd.sysfd, syscall.IPPROTO_TCP, syscall.TCP_KEEPIDLE, secs))
>>                                                                                                        ^
>
> I think this will be fixed by the appended patch.  Bootstrapped and
> tested on x86_64-unknown-linux-gnu, not that that proves anything.
> Committed to mainline.

works on Solaris 11, but not on Solaris 9 and 10 which lack
TCP_KEEPALIVE_THRESHOLD.  Even so, the file still doesn't compile:

/vol/gcc/src/hg/trunk/local/libgo/go/net/tcpsockopt_solaris.go:22:31: error: incompatible types in binary expression
  msecs := int(d.Nanoseconds() / time.Millisecond)
                               ^

and this still prevents compilation of net.lo:

/vol/gcc/src/hg/trunk/local/libgo/go/net/fd_select.go:90:30: error: use of undefined type 'pollServer'
 func (p *pollster) WaitFD(s *pollServer, nsec int64) (fd int, mode int, err error) {
                              ^
/vol/gcc/src/hg/trunk/local/libgo/go/net/fd_select.go:113:5: error: reference to field 'Unlock' in object which has no fields or methods
    s.Unlock()
     ^
/vol/gcc/src/hg/trunk/local/libgo/go/net/fd_select.go:115:5: error: reference to field 'Lock' in object which has no fields or methods
    s.Lock()
     ^

	Rainer
Ian Lance Taylor Nov. 12, 2013, 3:14 p.m. UTC | #2
On Tue, Nov 12, 2013 at 6:43 AM, Rainer Orth
<ro@cebitec.uni-bielefeld.de> wrote:
>
> works on Solaris 11, but not on Solaris 9 and 10 which lack
> TCP_KEEPALIVE_THRESHOLD.

Do they have any facility for changing the keepalive timers?

Ian
Rainer Orth Nov. 12, 2013, 3:16 p.m. UTC | #3
Ian Lance Taylor <iant@google.com> writes:

> On Tue, Nov 12, 2013 at 6:43 AM, Rainer Orth
> <ro@cebitec.uni-bielefeld.de> wrote:
>>
>> works on Solaris 11, but not on Solaris 9 and 10 which lack
>> TCP_KEEPALIVE_THRESHOLD.
>
> Do they have any facility for changing the keepalive timers?

There's TCP_KEEPALIVE which is already used in tcpsockopt_darwin.go.

	Rainer
diff mbox

Patch

diff -r 47a9c8a497d5 libgo/Makefile.am
--- a/libgo/Makefile.am	Mon Nov 11 13:20:11 2013 -0800
+++ b/libgo/Makefile.am	Mon Nov 11 13:23:07 2013 -0800
@@ -770,9 +770,13 @@ 
 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
 go_net_tcpsockopt_file =  go/net/tcpsockopt_unix.go
 endif
 endif
+endif
 
 go_net_files = \
 	go/net/cgo_unix.go \
diff -r 47a9c8a497d5 libgo/go/net/tcpsockopt_solaris.go
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libgo/go/net/tcpsockopt_solaris.go	Mon Nov 11 13:23:07 2013 -0800
@@ -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))
+}