1
0
mirror of https://github.com/golang/go synced 2024-10-04 02:31:22 -06:00
Commit Graph

24 Commits

Author SHA1 Message Date
Russ Cox
e1cf7d6fb6 net: fix spurious EADDRNOTAVAIL errors
R=golang-dev, fullung
CC=golang-dev
https://golang.org/cl/6443085
2012-08-06 16:32:00 -04:00
Dave Cheney
f72c828c67 net: consolidate common socket functions
In resolving 3507, the fix had to be applied individually to
the four *Conn types, tcp, udp, rawip and unix, due to the
duplicate code in each Conn type.

This CL consolidates the common net.Conn methods that all four
*Conn types implement into a base conn type.

Pros:
* The fix for 3507 would have only needed to be applied to one
method. Further improvements, such as possibly removing the
c.fd != nil check in c.ok(), would benefit from this CL.
* Nearly 300 lines removed from the net package.
* The public interface and documentation are not changed.
* I think this is an excellent example of the power of embedding.

Cons:
* The net package is already distributed over many files, this
CL adds another place to look.
* The fix for 3507 was a total of 16 lines changed, this follow
up CL could be considered to be an overreaction as new Conn types
are unlikely to be added in the near future.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6098047
2012-04-27 22:17:08 +10:00
Rémy Oudompheng
d1ab10b4ff net: fix typo in Listener.File() documentation
R=golang-dev, dave, rsc
CC=golang-dev, remy
https://golang.org/cl/6097044
2012-04-24 01:27:19 +02:00
Dave Cheney
1f14d45e7d net: fix race between Close and Read
Fixes #3507.

Applied the suggested fix from rsc. If the connection
is in closing state then errClosing will bubble up to
the caller.

The fix has been applied to udp, ip and unix as well as
their code path include nil'ing c.fd on close. Func
tests are available in the linked issue that verified
the bug existed there as well.

R=rsc, fullung, alex.brainman, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6002053
2012-04-21 10:01:32 +10:00
Brad Fitzpatrick
610b5b2fd8 net: remove all direct fmt and bytes imports
Once dnsMsg stops using reflect, we lose even more
indirect dependencies.

R=rsc
CC=golang-dev
https://golang.org/cl/5751043
2012-03-05 13:36:05 -08:00
Mikio Hara
b5dc8724cb net: make Dial and Listen behavior consistent across over platforms
This CL changes the behavior of Dial and Listen API family.

Previous Dial and Listen allow a combo of "tcp6" and IPv4 or IPv6
IPv4-mapped address as its argument, but it also makes slightly
different behaviors between Linux and other platforms. This CL fixes
such differences across over platforms by tweaking IP-level socket
option IPV6_V6ONLY. Consequently new Dial and Listen API family will
reject arguments consists of "tcp6" and IPv4 or IPv6 IPv4-mapped
address.

This CL also adds a bit clarified unicast listener tests.

Fixes #2581.

R=rsc, minux.ma
CC=golang-dev
https://golang.org/cl/5677086
2012-03-06 00:13:10 +09:00
Rob Pike
152d806b16 net: extend the workaround to DialTCP to try to get arm building again.
Awfulness by the bucket that we hope
Fixes #3057.

R=golang-dev, mikioh.mikioh, dsymonds, r, rsc
CC=golang-dev
https://golang.org/cl/5687060
2012-02-21 16:48:05 +11:00
Rob Pike
3970d2fd58 net: panic if sockaddrToTCP returns nil incorrectly
Part of diagnosing the selfConnect bug
TBR=dsymonds

R=golang-dev
CC=golang-dev
https://golang.org/cl/5687057
2012-02-21 15:21:34 +11:00
Rob Pike
2155a0408e net: add diagnostic to try to catch selfConnect bug earlier
TBR=dsymonds

R=golang-dev
CC=golang-dev
https://golang.org/cl/5683057
2012-02-21 14:53:07 +11:00
Rob Pike
56069f0333 os: delete os.EINVAL and so on
The set of errors forwarded by the os package varied with system and
was therefore non-portable.
Three helpers added for portable error checking: IsExist, IsNotExist, and IsPermission.
One or two more may need to come, but let's keep the set very small to discourage
thinking about errors that way.

R=mikioh.mikioh, gustavo, r, rsc
CC=golang-dev
https://golang.org/cl/5672047
2012-02-17 10:04:29 +11:00
Russ Cox
cbe7d8db24 net: avoid TCP self-connect
Fixes #2690.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5650071
2012-02-12 23:25:55 -05:00
Mikio Hara
28397befab net: replace error variable name e, errno with err
R=rsc, r
CC=golang-dev
https://golang.org/cl/5593046
2012-02-01 00:36:45 +09:00
Mikio Hara
3d400db5de net: update comments to remove redundant "net" prefix
R=rsc, r
CC=golang-dev
https://golang.org/cl/5569087
2012-01-29 19:11:05 +09:00
Mikio Hara
77cb8956a0 net: consistent OpError message
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5562047
2012-01-24 02:59:43 +09:00
Brad Fitzpatrick
b71883e9b0 net: change SetTimeout to SetDeadline
Previously, a timeout (in int64 nanoseconds) applied to a granularity
even smaller than one operation:  a 100 byte read with a 1 second timeout
could take 100 seconds, if the bytes all arrived on the network 1 second
apart.  This was confusing.

Rather than making the timeout granularity be per-Read/Write,
this CL makes callers set an absolute deadline (in time.Time)
after which operations will fail.  This makes it possible to
set deadlines at higher levels, without knowing exactly how
many read/write operations will happen in e.g. reading an HTTP
request.

Fixes #2723

R=r, rsc, dave
CC=golang-dev
https://golang.org/cl/5555048
2012-01-18 16:24:06 -08:00
Mikio Hara
d3c59f6ec8 net: make use of the kernel state to listen on TCP, Unix
R=golang-dev, dave, minux.ma
CC=golang-dev
https://golang.org/cl/5545044
2012-01-14 13:42:18 +09:00
Christopher Nielsen
d10126a622 os: OS-dependent bits to support NetBSD.
R=golang-dev, jsing
CC=golang-dev
https://golang.org/cl/5482068
2011-12-15 12:19:19 -05:00
Russ Cox
c017a8299f syscall: use error
- syscall (not os) now defines the Errno type.
- the low-level assembly functions Syscall, Syscall6, and so on
  return Errno, not uintptr
- syscall wrappers all return error, not uintptr.

R=golang-dev, mikioh.mikioh, r, alex.brainman
CC=golang-dev
https://golang.org/cl/5372080
2011-11-13 22:44:52 -05:00
Russ Cox
eb6929299b src/pkg/[n-z]*: gofix -r error -force=error
R=golang-dev, bsiegert, iant
CC=golang-dev
https://golang.org/cl/5294074
2011-11-01 22:05:34 -04:00
Brad Fitzpatrick
394842e2a5 net: add shutdown: TCPConn.CloseWrite and CloseRead
R=golang-dev, rsc, iant
CC=golang-dev
https://golang.org/cl/5136052
2011-09-28 08:12:38 -07:00
Russ Cox
2715956f13 build: add build comments to core packages
The go/build package already recognizes
system-specific file names like

        mycode_darwin.go
        mycode_darwin_386.go
        mycode_386.s

However, it is also common to write files that
apply to multiple architectures, so a recent CL added
to go/build the ability to process comments
listing a set of conditions for building.  For example:

        // +build darwin freebsd openbsd/386

says that this file should be compiled only on
OS X, FreeBSD, or 32-bit x86 OpenBSD systems.

These conventions are not yet documented
(hence this long CL description).

This CL adds build comments to the multi-system
files in the core library, a step toward making it
possible to use go/build to build them.

With this change go/build can handle crypto/rand,
exec, net, path/filepath, os/user, and time.

os and syscall need additional adjustments.

R=golang-dev, r, gri, r, gustavo
CC=golang-dev
https://golang.org/cl/5011046
2011-09-15 16:48:57 -04:00
Joel Sing
d130611f45 net: disable "tcp" test on openbsd
Doing a socket/listen on an unspecified address with an unspecified
address family is likely to result in an AF_INET6 socket on an IPv6
capable system, which under OpenBSD means IPv6 only - not IPv4 *and*
IPv6. In this case trying to connect to this socket from an IPv4
loopback address is not going to end well.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4807057
2011-08-26 15:38:02 -04:00
Mikio Hara
80f79ad305 net: make use of IPv4len, IPv6len
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4926046
2011-08-24 13:59:33 -04:00
Fazlul Shahriar
0f7bc92bdb net: Plan 9 support
All tests enabled by default passes except those in timeout_test.go.

For TestLookupPort, add an entry for "bootps" in /lib/ndb/common
(Plan 9 calls it "bootp"). I've sent out a patch to fix this.

R=paulzhol, rsc, mikioh.mikioh
CC=ality, golang-dev
https://golang.org/cl/4779041
2011-08-17 13:28:29 -04:00