1
0
mirror of https://github.com/golang/go synced 2024-10-05 09:21:22 -06:00
Commit Graph

979 Commits

Author SHA1 Message Date
Mikio Hara
e257cd8aae net: extend sockaddr interface to the all address families
This CL extends existing sockaddr interface to accommodate not only
internet protocol family endpoint addressess but unix network family
endpoint addresses.

This is in preparation for runtime-integrated network pollster for BSD
variants.

Update #5199

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/11979043
2013-07-28 12:52:30 +09:00
Mikio Hara
bf61a97f24 net: simplify socket option helpers
Also consolidates syscall.IPPROTO_TCP level option helper files.

R=golang-dev, dave, alex.brainman
CC=golang-dev
https://golang.org/cl/8637049
2013-07-28 11:18:06 +09:00
Dmitriy Vyukov
29f17fb01c net: temporary skip hanging test on windows
Update #5971.

R=alex.brainman
CC=golang-dev
https://golang.org/cl/11938046
2013-07-27 13:36:27 +04:00
Mikio Hara
cdd3598334 net: give more detail when test panics
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/11811043
2013-07-26 00:21:37 +09:00
Mikio Hara
c0a4ce52c6 net: simplify probeIPv6Stack
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/11807043
2013-07-25 19:29:20 +09:00
Mikio Hara
a0a45bbb71 net: consolidate listenerBacklog declaration
Also adds maxListenerBacklog placeholder for Plan 9.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/11674044
2013-07-24 08:43:08 +09:00
Brad Fitzpatrick
baa9ca032b net/http: respect tls.Config.ServerName in Transport
When making an HTTPS client request, respect the
ServerName field in the tls.Config.

Fixes #5829

R=golang-dev, agl, adg
CC=golang-dev
https://golang.org/cl/11691043
2013-07-22 22:39:09 -07:00
Rob Pike
abe384f68a all: be more idiomatic when documenting boolean return values.
Phrases like "returns whether or not the image is opaque" could be
describing what the function does (it always returns, regardless of
the opacity) or what it returns (a boolean indicating the opacity).
Even when the "or not" is missing, the phrasing is bizarre.

Go with "reports whether", which is still clunky but at least makes
it clear we're talking about the return value.

These were edited by hand. A few were cleaned up in other ways.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/11699043
2013-07-23 11:59:49 +10:00
Mikio Hara
7d9a8fb8a9 net: make use of noDeadline instead of time.Time{}
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/11691044
2013-07-23 10:13:58 +09:00
Mikio Hara
5d14b89933 net: remove unnecessary bit masking
R=dave
CC=golang-dev
https://golang.org/cl/11537044
2013-07-22 20:08:58 +09:00
Alex Brainman
6ea7bf253c net: implement netpoll for windows
Moves the network poller from net package into runtime.

benchmark                           old ns/op    new ns/op    delta
BenchmarkTCP4OneShot                   316386       287061   -9.27%
BenchmarkTCP4OneShot-2                 339822       313424   -7.77%
BenchmarkTCP4OneShot-3                 330057       306589   -7.11%
BenchmarkTCP4OneShotTimeout            341775       287061  -16.01%
BenchmarkTCP4OneShotTimeout-2          380835       295849  -22.32%
BenchmarkTCP4OneShotTimeout-3          398412       328070  -17.66%
BenchmarkTCP4Persistent                 40622        33392  -17.80%
BenchmarkTCP4Persistent-2               44528        35736  -19.74%
BenchmarkTCP4Persistent-3               44919        36907  -17.84%
BenchmarkTCP4PersistentTimeout          45309        33588  -25.87%
BenchmarkTCP4PersistentTimeout-2        50289        38079  -24.28%
BenchmarkTCP4PersistentTimeout-3        51559        37103  -28.04%
BenchmarkTCP6OneShot                   361305       345645   -4.33%
BenchmarkTCP6OneShot-2                 361305       331976   -8.12%
BenchmarkTCP6OneShot-3                 376929       347598   -7.78%
BenchmarkTCP6OneShotTimeout            361305       322212  -10.82%
BenchmarkTCP6OneShotTimeout-2          378882       333928  -11.86%
BenchmarkTCP6OneShotTimeout-3          388647       335881  -13.58%
BenchmarkTCP6Persistent                 47653        35345  -25.83%
BenchmarkTCP6Persistent-2               49215        35736  -27.39%
BenchmarkTCP6Persistent-3               38474        37493   -2.55%
BenchmarkTCP6PersistentTimeout          56637        34369  -39.32%
BenchmarkTCP6PersistentTimeout-2        42575        38079  -10.56%
BenchmarkTCP6PersistentTimeout-3        44137        37689  -14.61%

R=dvyukov
CC=golang-dev
https://golang.org/cl/8670044
2013-07-22 12:49:57 +10:00
Brad Fitzpatrick
b2b15d1230 net/http: document and test Client.Post treating Reader body as ReadCloser
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/11542044
2013-07-19 12:02:54 +10:00
Brad Fitzpatrick
4aa6d35306 net/http: document NewRequest treating Reader as ReadCloser
R=golang-dev, dsymonds, rogpeppe
CC=golang-dev
https://golang.org/cl/11432044
2013-07-18 10:10:10 +10:00
Joel Sing
9bd32b48ca net: fix setsockopt for openbsd
s/TCP_KEEPALIVE/SO_KEEPALIVE/ to unbreak build on OpenBSD.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/11345044
2013-07-16 08:35:06 -07:00
David Presotto
918922cf85 net: add SetKeepAlivePeriod
Sets both the duration from the last data packet to the first
keep alive packet and the duration between keep alive packets to be
the passed duration.

I've tested the function on both Darwin (10.8.4) and 4.2 Linux.
I've compiled (make.bash) for all the OS's and tested (all.bash)
on Darwin and Linux.

R=golang-dev, dave, rsc, dvyukov, presotto+facebook, nick
CC=golang-dev, veyron-team
https://golang.org/cl/11130044
2013-07-15 18:40:55 -04:00
ChaiShushan
735cf52983 net/rpc: fix a test bug
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/10855043
2013-07-11 15:55:08 -04:00
Brad Fitzpatrick
d178c016c2 net/http: in ServeContent, don't seek on content until necessary
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/11080043
2013-07-10 13:29:52 +10:00
ChaiShushan
e23d19e235 net/rpc: use log.Print and return error instead log.Fatal
R=r
CC=golang-dev
https://golang.org/cl/10758044
2013-07-09 11:12:05 +10:00
Brad Fitzpatrick
16c3f82ed4 net/textproto: reduce allocations in ReadMIMEHeader
ReadMIMEHeader is used by net/http, net/mail, and
mime/multipart.

Don't do so many small allocations. Calculate up front
how much we'll probably need.

benchmark                  old ns/op    new ns/op    delta
BenchmarkReadMIMEHeader         8433         7467  -11.45%

benchmark                 old allocs   new allocs    delta
BenchmarkReadMIMEHeader           23           14  -39.13%

benchmark                  old bytes    new bytes    delta
BenchmarkReadMIMEHeader         1705         1343  -21.23%

R=golang-dev, r, iant, adg
CC=golang-dev
https://golang.org/cl/8179043
2013-07-02 22:37:19 -07:00
ChaiShushan
456f6df96a net/rpc: remove unnecessary code
Fixes #5760.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/10871043
2013-07-02 17:29:21 -07:00
ChaiShushan
b86f6c9224 net/rpc/jsonrpc: remove unused serverCodec.resp field
R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/10458045
2013-07-01 21:20:42 -04:00
Brad Fitzpatrick
46161cd079 net/http: fix memory leak in Transport
Fixes #5794

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/10747044
2013-06-28 12:57:54 -07:00
Rick Arnold
64441d6d66 net/smtp: preserve Auth errors
If authentication failed, the initial error was being thrown away.

Fixes #5700.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/10744043
2013-06-28 12:24:45 -07:00
Alex Brainman
8486d96a27 runtime: change netpoll in preparation for windows implementation
- change runtime_pollWait so it does not return
  closed or timeout if IO is ready - windows must
  know if IO has completed or not even after
  interruption;
- add (*pollDesc).Prepare(mode int) that can be
  used for both read and write, same for Wait;
- introduce runtime_pollWaitCanceled and expose
  it in net as (*pollDesc).WaitCanceled(mode int);

Full windows netpoll changes are
here https://golang.org/cl/8670044/.

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/10485043
2013-06-25 12:29:00 +10:00
Brad Fitzpatrick
a054028471 net/http: Transport should return an error when response body ends early
If a server response contains a Content-Length and the body is short,
the Transport should end in io.ErrUnexpectedEOF, not io.EOF.

Fixes #5738

R=golang-dev, kevlar, r
CC=golang-dev
https://golang.org/cl/10237050
2013-06-24 13:27:56 -07:00
ChaiShushan
3eaaed5030 net/rpc: fix RegisterName rejects "." character.
Fixes #5617.

R=r, rsc
CC=gobot, golang-dev
https://golang.org/cl/10370043
2013-06-24 13:23:02 -07:00
ChaiShushan
b78aaec22f net/rpc: call client.Close() when test exit
Fixes #5768.

R=golang-dev
CC=golang-dev
https://golang.org/cl/10503043
2013-06-24 13:18:50 -07:00
Dave Cheney
a00958aac6 all: avoid leaking fds during tests
trivial: it is not a serious problem to leak a fd in a short lived process, but it was obscuring my investigation of issue 5593.

R=golang-dev, iant, bradfitz
CC=golang-dev
https://golang.org/cl/10391043
2013-06-21 11:13:14 +10:00
Rob Pike
0bc7e79afd all: excise some warts found by vet -shadow
These are not erroneous, just poor or confusing.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/10448043
2013-06-20 16:14:40 -07:00
Brad Fitzpatrick
5b0bf9db8e net/http: fix confusing shadowing in ProxyFromEnvironment
The old code worked, somewhat on accident, but was confusing,
and had a useless assignment to the inner err. It worked
because url.Parse parses just about anything, so the outer err
was always nil, so it always fell through to the bottom return
statement, even without the "err = nil" line.

Instead, just have two return statements, and add a comment.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/10448044
2013-06-20 11:58:24 -07:00
Rob Pike
3e710c0ba5 all: fix shadowing bugs found by go tool vet -shadow
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/10328044
2013-06-20 11:50:44 -07:00
Alex Jin
83db738786 net/smtp: close conn in SendMail; add Client.Close method
R=rsc, dave, bradfitz
CC=golang-dev
https://golang.org/cl/10082044
2013-06-17 16:53:27 -07:00
Nicolas Owens
2af974777d net: fix LookupNS on Plan 9
use correct field count when resolving nameservers via /net/dns on Plan 9.

we incorrectly check for 4 fields instead of 3 when parsing the result of /net/dns, and get no results

R=golang-dev, ality
CC=golang-dev
https://golang.org/cl/10182044
2013-06-17 11:38:07 -07:00
Brad Fitzpatrick
61d3b2db62 net: coalesce duplicate in-flight DNS lookups
In Issue 5625, Russ says: "We should at least have a cache of
inflight lookups, so that 100 simultaneous dials of one host
name don't do the work 100x. That's easy and (assume we forget
the answer once they all get it) doesn't pose any consistency
problems. It just merges simultaneous work."

This brings in singleflight (unexported) from Google /
Camlistore, but without its tests. Maybe we should put it
somewhere in the standard library. But not now.

Update #5625

R=golang-dev, iant, cespare, rsc, dave, rogpeppe, remyoudompheng
CC=golang-dev
https://golang.org/cl/10079043
2013-06-14 08:59:43 -07:00
Shenghou Ma
06f55f5009 net: introduce netgo build tag to build a pure Go net package.
Fixes #4078.

R=golang-dev, bradfitz, rsc, iant
CC=golang-dev
https://golang.org/cl/7100050
2013-06-11 02:55:16 +08:00
Brad Fitzpatrick
950fa93531 net/http: add another Hijacker test
R=dsymonds
CC=gobot, golang-dev
https://golang.org/cl/9570043
2013-05-21 18:43:28 -07:00
Brad Fitzpatrick
ddda7980c5 net/http: don't send Accept-Encoding on HEAD requests
Works around a bug in nginx: http://trac.nginx.org/nginx/ticket/358

Fixes #5522

R=iant
CC=gobot, golang-dev
https://golang.org/cl/9627043
2013-05-21 15:21:30 -07:00
Brad Fitzpatrick
c6c439d7a0 net/http: use WriteString directly when possible
Several places used io.WriteString unnecessarily when the
static type already implemented WriteString. No need to
check for it at runtime.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9608043
2013-05-20 19:26:26 -07:00
Brad Fitzpatrick
27f7427995 net/http: simplify transfer body; reduces allocations too
benchmark                                   old ns/op    new ns/op    delta
BenchmarkServerFakeConnNoKeepAlive              14431        14247   -1.28%
BenchmarkServerFakeConnWithKeepAlive            11618        11357   -2.25%
BenchmarkServerFakeConnWithKeepAliveLite         6735         6427   -4.57%
BenchmarkServerHandlerTypeLen                    8842         8740   -1.15%
BenchmarkServerHandlerNoLen                      8001         7828   -2.16%
BenchmarkServerHandlerNoType                     8270         8227   -0.52%
BenchmarkServerHandlerNoHeader                   6148         5920   -3.71%

benchmark                                  old allocs   new allocs    delta
BenchmarkServerFakeConnNoKeepAlive                 30           29   -3.33%
BenchmarkServerFakeConnWithKeepAlive               25           24   -4.00%
BenchmarkServerFakeConnWithKeepAliveLite           10            9  -10.00%
BenchmarkServerHandlerTypeLen                      18           17   -5.56%
BenchmarkServerHandlerNoLen                        15           14   -6.67%
BenchmarkServerHandlerNoType                       16           15   -6.25%
BenchmarkServerHandlerNoHeader                     10            9  -10.00%

benchmark                                   old bytes    new bytes    delta
BenchmarkServerFakeConnNoKeepAlive               2557         2492   -2.54%
BenchmarkServerFakeConnWithKeepAlive             2260         2194   -2.92%
BenchmarkServerFakeConnWithKeepAliveLite         1092         1026   -6.04%
BenchmarkServerHandlerTypeLen                    1941         1875   -3.40%
BenchmarkServerHandlerNoLen                      1898         1832   -3.48%
BenchmarkServerHandlerNoType                     1906         1840   -3.46%
BenchmarkServerHandlerNoHeader                   1092         1026   -6.04%

Update #5195

R=golang-dev, daniel.morsing
CC=golang-dev
https://golang.org/cl/9492044
2013-05-20 07:23:59 -07:00
Alex Brainman
1a948950f7 net: move system common global variables into fd_unix.go
R=golang-dev, bradfitz
CC=dvyukov, golang-dev, mikioh.mikioh
https://golang.org/cl/9495044
2013-05-20 15:23:45 +10:00
Brad Fitzpatrick
d4cbc80d10 net/http: fewer allocations in the server path
Don't allocate for the Date or Content-Length headers.
A custom Date header formatter replaces use of time.Format.

benchmark                                   old ns/op    new ns/op    delta
BenchmarkClientServer                           67791        64424   -4.97%
BenchmarkClientServerParallel4                  62956        58533   -7.03%
BenchmarkClientServerParallel64                 62043        54789  -11.69%
BenchmarkServer                                254609       229060  -10.03%
BenchmarkServerFakeConnNoKeepAlive              17038        16316   -4.24%
BenchmarkServerFakeConnWithKeepAlive            14184        13226   -6.75%
BenchmarkServerFakeConnWithKeepAliveLite         8591         7532  -12.33%
BenchmarkServerHandlerTypeLen                   10750         9961   -7.34%
BenchmarkServerHandlerNoLen                      9535         8935   -6.29%
BenchmarkServerHandlerNoType                     9858         9362   -5.03%
BenchmarkServerHandlerNoHeader                   7754         6856  -11.58%

benchmark                                  old allocs   new allocs    delta
BenchmarkClientServer                              68           66   -2.94%
BenchmarkClientServerParallel4                     68           66   -2.94%
BenchmarkClientServerParallel64                    68           66   -2.94%
BenchmarkServer                                    21           19   -9.52%
BenchmarkServerFakeConnNoKeepAlive                 32           30   -6.25%
BenchmarkServerFakeConnWithKeepAlive               27           25   -7.41%
BenchmarkServerFakeConnWithKeepAliveLite           12           10  -16.67%
BenchmarkServerHandlerTypeLen                      19           18   -5.26%
BenchmarkServerHandlerNoLen                        17           15  -11.76%
BenchmarkServerHandlerNoType                       17           16   -5.88%
BenchmarkServerHandlerNoHeader                     12           10  -16.67%

Update #5195

R=nigeltao
CC=golang-dev
https://golang.org/cl/9432046
2013-05-19 20:15:40 -07:00
Alex Brainman
38abb09a2e runtime: change PollDesc.fd from int32 to uintptr
This is in preparation for netpoll windows version.

R=golang-dev, bradfitz
CC=dvyukov, golang-dev, mikioh.mikioh
https://golang.org/cl/9569043
2013-05-20 12:55:50 +10:00
Alberto García Hierro
d535bc7af3 net/http: Fix basic authentication with empty password
The encoded string must include the : separating the username
        and the password, even when the latter is empty. See
        http://www.ietf.org/rfc/rfc2617.txt for more information.

R=golang-dev, bradfitz, adg
CC=golang-dev
https://golang.org/cl/8475043
2013-05-14 15:33:46 -07:00
Alex Brainman
e1922febbe net: fix dial race on plan9 and windows
Fixes #5349.

R=golang-dev, lucio.dere, dsymonds, bradfitz, iant, adg, dave, r
CC=golang-dev
https://golang.org/cl/9159043
2013-05-08 16:19:02 +10:00
Alex Brainman
ca6b1f3eeb net: do not call syscall.Bind twice on windows
Fixes #5355.

R=golang-dev, mikioh.mikioh, bradfitz, r
CC=golang-dev
https://golang.org/cl/8966046
2013-04-30 17:47:39 -07:00
Andrew Gerrand
13721cf688 net/http/httptest: fix incorrectly-named ResponseRecorder example
R=golang-dev, minux.ma, r
CC=golang-dev
https://golang.org/cl/8545047
2013-04-29 17:34:47 +02:00
Mikio Hara
2bd17bca07 net: deflake raw IP protocol entry test on Windows
Update #5344

R=golang-dev, dave, r, alex.brainman
CC=golang-dev
https://golang.org/cl/8934043
2013-04-25 13:23:24 +09:00
Mikio Hara
73417e4098 net: add missing File method document
R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/8698049
2013-04-24 08:32:11 +09:00
Shenghou Ma
7bec1a6033 all: fix typos
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/8896045
2013-04-24 04:46:14 +08:00
Mikio Hara
3828316b9f net: fix protocol number for IPv6 test
The protocol number of ICMP for IPv6 is 58, not 1.

R=golang-dev, iant, r
CC=golang-dev
https://golang.org/cl/8663048
2013-04-23 20:30:42 +09:00