1. 18 Apr, 2015 4 commits
  2. 31 Mar, 2015 1 commit
    • Mikio Hara's avatar
      net: add socket system call hooks for testing · 29d1f3b8
      Mikio Hara authored
      This change adds socket system call hooks to existing test cases for
      simulating a bit complicated network conditions to help making timeout
      and dual IP stack test cases work more properly in followup changes.
      
      Also test cases print debugging information in non-short mode like the
      following:
      
      Leaked goroutines:
      net.TestWriteTimeout.func2(0xc20802a5a0, 0xc20801d000, 0x1000, 0x1000, 0xc2081d2ae0)
      	/go/src/net/timeout_test.go:170 +0x98
      created by net.TestWriteTimeout
      	/go/src/net/timeout_test.go:173 +0x745
      net.runDatagramPacketConnServer(0xc2080730e0, 0x2bd270, 0x3, 0x2c1770, 0xb, 0xc2081d2ba0, 0xc2081d2c00)
      	/go/src/net/server_test.go:398 +0x667
      created by net.TestTimeoutUDP
      	/go/src/net/timeout_test.go:247 +0xc9
      	(snip)
      
      Leaked sockets:
      3: {Cookie:615726511685632 Err:<nil> SocketErr:0}
      5: {Cookie:7934075906097152 Err:<nil> SocketErr:0}
      
      Socket statistical information:
      {Family:1 Type:805306370 Protocol:0 Opened:17 Accepted:0 Connected:5 Closed:17}
      {Family:2 Type:805306369 Protocol:0 Opened:450 Accepted:234 Connected:279 Closed:636}
      {Family:1 Type:805306369 Protocol:0 Opened:11 Accepted:5 Connected:5 Closed:16}
      {Family:28 Type:805306369 Protocol:0 Opened:95 Accepted:22 Connected:16 Closed:116}
      {Family:2 Type:805306370 Protocol:0 Opened:84 Accepted:0 Connected:34 Closed:83}
      {Family:28 Type:805306370 Protocol:0 Opened:52 Accepted:0 Connected:4 Closed:52}
      
      Change-Id: I0e84be59a0699bc31245c78e2249423459b8cdda
      Reviewed-on: https://go-review.googlesource.com/6390
      
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      29d1f3b8
  3. 04 Feb, 2015 1 commit
  4. 29 Jan, 2015 1 commit
  5. 01 Jan, 2015 1 commit
  6. 08 Sep, 2014 1 commit
  7. 04 Aug, 2014 1 commit
  8. 29 Jul, 2014 1 commit
    • Mikio Hara's avatar
      net: prevent spurious on-connect events via epoll on linux · c0325f50
      Mikio Hara authored
      On Linux, adding a socket descriptor to epoll instance before getting
      the EINPROGRESS return value from connect system call could be a root
      cause of spurious on-connect events.
      
      See golang.org/issue/8276, golang.org/issue/8426 for further information.
      
      All credit to Jason Eggleston <jason@eggnet.com>
      
      Fixes #8276.
      Fixes #8426.
      
      LGTM=dvyukov
      R=dvyukov, golang-codereviews, adg, dave, iant, alex.brainman
      CC=golang-codereviews
      https://golang.org/cl/120820043
      c0325f50
  9. 27 Apr, 2014 1 commit
  10. 25 Apr, 2014 1 commit
  11. 04 Apr, 2014 1 commit
  12. 03 Apr, 2014 1 commit
  13. 24 Mar, 2014 1 commit
  14. 05 Mar, 2014 1 commit
    • Joel Sing's avatar
      net: fix non-blocking connect handling on dragonfly · 734d4637
      Joel Sing authored
      Performing multiple connect system calls on a non-blocking socket
      under DragonFly BSD does not necessarily result in errors from earlier
      connect calls being returned, particularly if we are connecting to
      localhost. Instead, once netpoll tells us that the socket is ready,
      get the SO_ERROR socket option to see if the connection succeeded
      or failed.
      
      Fixes #7474
      
      LGTM=mikioh.mikioh
      R=mikioh.mikioh
      CC=golang-codereviews
      https://golang.org/cl/69340044
      734d4637
  15. 25 Feb, 2014 2 commits
    • Dave Cheney's avatar
      all: merge NaCl branch (part 1) · 7c8280c9
      Dave Cheney authored
      See golang.org/s/go13nacl for design overview.
      
      This CL is the mostly mechanical changes from rsc's Go 1.2 based NaCl branch, specifically 39cb35750369 to 500771b477cf from https://code.google.com/r/rsc-go13nacl. This CL does not include working NaCl support, there are probably two or three more large merges to come.
      
      CL 15750044 is not included as it involves more invasive changes to the linker which will need to be merged separately.
      
      The exact change lists included are
      
      15050047: syscall: support for Native Client
      15360044: syscall: unzip implementation for Native Client
      15370044: syscall: Native Client SRPC implementation
      15400047: cmd/dist, cmd/go, go/build, test: support for Native Client
      15410048: runtime: support for Native Client
      15410049: syscall: file descriptor table for Native Client
      15410050: syscall: in-memory file system for Native Client
      15440048: all: update +build lines for Native Client port
      15540045: cmd/6g, cmd/8g, cmd/gc: support for Native Client
      15570045: os: support for Native Client
      15680044: crypto/..., hash/crc32, reflect, sync/atomic: support for amd64p32
      15690044: net: support for Native Client
      15690048: runtime: support for fake time like on Go Playground
      15690051: build: disable various tests on Native Client
      
      LGTM=rsc
      R=rsc
      CC=golang-codereviews
      https://golang.org/cl/68150047
      7c8280c9
    • Aram Hăvărneanu's avatar
      runtime, net: add support for GOOS=solaris · 50df1364
      Aram Hăvărneanu authored
      LGTM=dave, rsc
      R=golang-codereviews, minux.ma, mikioh.mikioh, dave, iant, rsc
      CC=golang-codereviews
      https://golang.org/cl/36030043
      50df1364
  16. 28 Dec, 2013 1 commit
    • Ian Lance Taylor's avatar
      net: work around Solaris connect issue when server closes socket · 672525a5
      Ian Lance Taylor authored
      On Solaris, if you do a in-progress connect, and then the
      server accepts and closes the socket, the client's later
      attempt to complete the connect will fail with EINVAL.  Handle
      this case by assuming that the connect succeeded.  This code
      is weird enough that it is implemented as Solaris-only so that
      it doesn't hide a real error on a different OS.
      
      Update #6828
      
      R=golang-codereviews, bradfitz, dave
      CC=golang-codereviews
      https://golang.org/cl/46160043
      672525a5
  17. 24 Sep, 2013 1 commit
  18. 11 Sep, 2013 1 commit
    • Mikio Hara's avatar
      net: implement TCP connection setup with fast failover · 89b26760
      Mikio Hara authored
      This CL adds minimal support of Happy Eyeballs-like TCP connection
      setup to Dialer API. Happy Eyeballs and derivation techniques are
      described in the following:
      
      - Happy Eyeballs: Success with Dual-Stack Hosts
        http://tools.ietf.org/html/rfc6555
      
      - Analysing Dual Stack Behaviour and IPv6 Quality
        http://www.potaroo.net/presentations/2012-04-17-dual-stack-quality.pdf
      
      Usually, the techniques consist of three components below.
      
      - DNS query racers, that run A and AAAA queries in parallel or series
      - A short list of destination addresses
      - TCP SYN racers, that run IPv4 and IPv6 transport in parallel or series
      
      This CL implements only the latter two. The existing DNS query
      component gathers together A and AAAA records in series, so we don't
      touch it here. This CL just uses extended resolveInternetAddr and makes
      it possible to run multiple Dial racers in parallel.
      
      For example, when the given destination is a DNS name and the name has
      multiple address family A and AAAA records, and it happens on the TCP
      wildcard network "tcp" with DualStack=true like the following:
      
      (&net.Dialer{DualStack: true}).Dial("tcp", "www.example.com:80")
      
      The function will return a first established connection either TCP over
      IPv4 or TCP over IPv6, and close the other connection internally.
      
      Fixes #3610.
      Fixes #5267.
      
      Benchmark results on freebsd/amd64 virtual machine, tip vs. tip+12416043:
      
      benchmark                           old ns/op    new ns/op    delta
      BenchmarkTCP4OneShot                    50696        52141   +2.85%
      BenchmarkTCP4OneShotTimeout             65775        66426   +0.99%
      BenchmarkTCP4Persistent                 10986        10457   -4.82%
      BenchmarkTCP4PersistentTimeout          11207        10445   -6.80%
      BenchmarkTCP6OneShot                    62009        63718   +2.76%
      BenchmarkTCP6OneShotTimeout             78351        79138   +1.00%
      BenchmarkTCP6Persistent                 14695        14659   -0.24%
      BenchmarkTCP6PersistentTimeout          15032        14646   -2.57%
      BenchmarkTCP4ConcurrentReadWrite         7215         6217  -13.83%
      BenchmarkTCP6ConcurrentReadWrite         7528         7493   -0.46%
      
      benchmark                          old allocs   new allocs    delta
      BenchmarkTCP4OneShot                       36           36    0.00%
      BenchmarkTCP4OneShotTimeout                36           36    0.00%
      BenchmarkTCP4Persistent                     0            0     n/a%
      BenchmarkTCP4PersistentTimeout              0            0     n/a%
      BenchmarkTCP6OneShot                       37           37    0.00%
      BenchmarkTCP6OneShotTimeout                37           37    0.00%
      BenchmarkTCP6Persistent                     0            0     n/a%
      BenchmarkTCP6PersistentTimeout              0            0     n/a%
      BenchmarkTCP4ConcurrentReadWrite            0            0     n/a%
      BenchmarkTCP6ConcurrentReadWrite            0            0     n/a%
      
      benchmark                           old bytes    new bytes    delta
      BenchmarkTCP4OneShot                     2500         2503    0.12%
      BenchmarkTCP4OneShotTimeout              2508         2505   -0.12%
      BenchmarkTCP4Persistent                     0            0     n/a%
      BenchmarkTCP4PersistentTimeout              0            0     n/a%
      BenchmarkTCP6OneShot                     2713         2707   -0.22%
      BenchmarkTCP6OneShotTimeout              2722         2720   -0.07%
      BenchmarkTCP6Persistent                     0            0     n/a%
      BenchmarkTCP6PersistentTimeout              0            0     n/a%
      BenchmarkTCP4ConcurrentReadWrite            0            0     n/a%
      BenchmarkTCP6ConcurrentReadWrite            0            0     n/a%
      
      R=golang-dev, bradfitz, nightlyone, rsc
      CC=golang-dev
      https://golang.org/cl/12416043
      89b26760
  19. 30 Aug, 2013 1 commit
    • Mikio Hara's avatar
      net: add netaddr interface · 3c6558ad
      Mikio Hara authored
      This CL adds the netaddr interface that will carry a single network
      endpoint address or a short list of IP addresses to dial helper
      functions in the upcoming CLs.
      
      This is in preparation for TCP connection setup with fast failover on
      dual IP stack node as described in RFC 6555.
      
      Update #3610
      Update #5267
      
      R=golang-dev, bradfitz
      CC=golang-dev
      https://golang.org/cl/13368044
      3c6558ad
  20. 27 Aug, 2013 1 commit
  21. 23 Aug, 2013 1 commit
  22. 13 Aug, 2013 1 commit
  23. 09 Aug, 2013 1 commit
    • Dmitriy Vyukov's avatar
      net: add special netFD mutex · 23e15f72
      Dmitriy Vyukov authored
      The mutex, fdMutex, handles locking and lifetime of sysfd,
      and serializes Read and Write methods.
      This allows to strip 2 sync.Mutex.Lock calls,
      2 sync.Mutex.Unlock calls, 1 defer and some amount
      of misc overhead from every network operation.
      
      On linux/amd64, Intel E5-2690:
      benchmark                             old ns/op    new ns/op    delta
      BenchmarkTCP4Persistent                    9595         9454   -1.47%
      BenchmarkTCP4Persistent-2                  8978         8772   -2.29%
      BenchmarkTCP4ConcurrentReadWrite           4900         4625   -5.61%
      BenchmarkTCP4ConcurrentReadWrite-2         2603         2500   -3.96%
      
      In general it strips 70-500 ns from every network operation depending
      on processor model. On my relatively new E5-2690 it accounts to ~5%
      of network op cost.
      
      Fixes #6074.
      
      R=golang-dev, bradfitz, alex.brainman, iant, mikioh.mikioh
      CC=golang-dev
      https://golang.org/cl/12418043
      23e15f72
  24. 06 Aug, 2013 2 commits
    • Mikio Hara's avatar
      net: separate pollster initialization from network file descriptor allocation · 6a76bca3
      Mikio Hara authored
      Unlike the existing net package own pollster, runtime-integrated
      network pollster on BSD variants, actually kqueue, requires a socket
      that has beed passed to syscall.Listen previously for a stream
      listener.
      
      This CL separates pollDesc.Init (actually runtime_pollOpen) from newFD
      to allow control of each state of sockets and adds init method to netFD
      instead. Upcoming CLs will rearrange the call order of runtime-integrated
      pollster and syscall functions like the following;
      
      - For dialers that open active connections, runtime_pollOpen will be
        called in between syscall.Bind and syscall.Connect.
      
      - For stream listeners that open passive stream connections,
        runtime_pollOpen will be called just after syscall.Listen.
      
      - For datagram listeners that open datagram connections,
        runtime_pollOpen will be called just after syscall.Bind.
      
      This is in preparation for runtime-integrated network pollster for BSD
      variants.
      
      Update #5199
      
      R=dvyukov, alex.brainman, minux.ma
      CC=golang-dev
      https://golang.org/cl/8608044
      6a76bca3
    • Brad Fitzpatrick's avatar
      net: detect bad F_DUPFD_CLOEXEC on OS X 10.6 · b2fcdfa5
      Brad Fitzpatrick authored
      On 10.6, OS X's fcntl returns EBADF instead of EINVAL.
      
      R=golang-dev, iant, dave
      CC=golang-dev
      https://golang.org/cl/12493043
      b2fcdfa5
  25. 05 Aug, 2013 1 commit
  26. 30 Jul, 2013 1 commit
  27. 20 May, 2013 1 commit
  28. 01 May, 2013 1 commit
  29. 09 Apr, 2013 1 commit
  30. 02 Apr, 2013 1 commit
  31. 21 Mar, 2013 1 commit
    • Dmitriy Vyukov's avatar
      runtime: explicitly remove fd's from epoll waitset before close() · 44840786
      Dmitriy Vyukov authored
      Fixes #5061.
      
      Current code relies on the fact that fd's are automatically removed from epoll set when closed. However, it is not true. Underlying file description is removed from epoll set only when *all* fd's referring to it are closed.
      
      There are 2 bad consequences:
      1. Kernel delivers notifications on already closed fd's.
      2. The following sequence of events leads to error:
         - add fd1 to epoll
         - dup fd1 = fd2
         - close fd1 (not removed from epoll since we've dup'ed the fd)
         - dup fd2 = fd1 (get the same fd as fd1)
         - add fd1 to epoll = EEXIST
      
      So, if fd can be potentially dup'ed of fork'ed, it's necessary to explicitly remove the fd from epoll set.
      
      R=golang-dev, bradfitz, dave
      CC=golang-dev
      https://golang.org/cl/7870043
      44840786
  32. 14 Mar, 2013 1 commit
  33. 12 Mar, 2013 1 commit
  34. 07 Mar, 2013 2 commits
    • Dmitriy Vyukov's avatar
      net: more refactoring in preparation for runtime integrated pollster · b000f228
      Dmitriy Vyukov authored
      Move pollServer from fd_unix.go to fd_poll_unix.go.
      Add pollServerInit(*NetFD) to allow custom initialization.
      Add pollServer.Close(*NetFD) to allow custom finalization.
      Move setDeadline() to fd_poll_unix.go to allow custom handling of deadlines.
      Move newPollServer() to fd_poll_unix.go to allow custom initialization.
      No logical code changes.
      The next step will be to turn off fd_poll_unix.go for some platform
      (I have changes for darwin/linux) and redirect it into runtime. See:
      https://golang.org/cl/7569043/diff/2001/src/pkg/net/fd_poll_runtime.go
      
      R=golang-dev, bradfitz
      CC=golang-dev
      https://golang.org/cl/7513045
      b000f228
    • Dmitriy Vyukov's avatar
      net: fix accept/connect deadline handling · 0f136f2c
      Dmitriy Vyukov authored
      Ensure that accept/connect respect deadline,
      even if the operation can be executed w/o blocking.
      Note this changes external behavior, but it makes
      it consistent with read/write.
      Factor out deadline check into pollServer.PrepareRead/Write,
      in preparation for edge triggered pollServer.
      Ensure that pollServer.WaitRead/Write are not called concurrently
      by adding rio/wio locks around connect/accept.
      
      R=golang-dev, mikioh.mikioh, bradfitz, iant
      CC=golang-dev
      https://golang.org/cl/7436048
      0f136f2c