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

6979 Commits

Author SHA1 Message Date
Alex Brainman
87b315a78f net: add missing close socket code
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6868067
2012-12-05 15:13:03 +11:00
Frithjof Schulze
cfc0a59d6e container/heap: Simplify the example.
Using append simplifies the code and makes it work if
the initial capacity of the slice is smaller than the
number of items pushed.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/6869060
2012-12-04 14:11:33 -08:00
Brad Fitzpatrick
add1bed735 net/http: clarify that Request.Host may contain a port number
Fixes #4172

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6872055
2012-12-04 07:09:01 -08:00
Alex Brainman
0420eb3b65 net: report Accept error during TestVariousDeadlines1Proc test
R=golang-dev
CC=golang-dev
https://golang.org/cl/6868057
2012-12-04 17:00:19 +11:00
Rémy Oudompheng
b1c4a8efa9 bytes: avoid duplicate malloc/copy in Buffer.ReadString
Twice faster and twice less garbage.

R=golang-dev, dave, daniel.morsing, bradfitz
CC=golang-dev
https://golang.org/cl/6849128
2012-12-03 14:04:18 +01:00
Mikio Hara
19d793a327 net: simplify ListenTCP
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/6875044
2012-12-03 20:00:50 +09:00
Luit van Drongelen
882953f62c encoding/gob: Fix typo in doc.go
Exactly how I find minute details like this is beyond me.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6842125
2012-12-01 15:15:14 -08:00
Johan Euphrosine
d7b0f2a524 math/rand: remove noop iteration in Perm
The first iteration always do `m[0], m[0] = m[0], m[0]`, because
`rand.Intn(1)` is 0.

fun note: IIRC in TAOCP version of this algorithm, `i` goes
backward (n-1->1), meaning that the "already" shuffled part of the
array is never altered betweens iterations, while in the current
implementation the "not-yet" shuffled part of the array is
conserved between iterations.

R=golang-dev
CC=golang-dev
https://golang.org/cl/6845121
2012-12-01 14:11:46 -08:00
Brad Fitzpatrick
444b7b53e0 crypto/tls: fix loading keys labeled just "PRIVATE KEY"
Worked in Go 1, broken in f440e65f93fe.

Fixes #4477

R=golang-dev, agl
CC=golang-dev
https://golang.org/cl/6865043
2012-12-01 11:02:08 -08:00
Rémy Oudompheng
b18a7c7cae net: remove unnecessary Close contention.
Contention profile in BenchmarkTCPOneShot (Core 2 Quad):

Before
Total: 80.285 seconds
44.743  55.7%  55.7%   44.743  55.7% runtime.chanrecv1
31.995  39.9%  95.6%   31.995  39.9% sync.(*Mutex).Lock
 3.547   4.4% 100.0%    3.547   4.4% runtime.chansend1

After
Total: 48.341 seconds
45.810  94.8%  94.8%   45.810  94.8% runtime.chanrecv1
 2.530   5.2% 100.0%    2.530   5.2% runtime.chansend1
 0.001   0.0% 100.0%    0.001   0.0% sync.(*Mutex).Lock

R=golang-dev, dave, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6845119
2012-12-01 09:26:07 +01:00
Mikio Hara
e3e885bb48 net: allow "" as a hint wildcard to Resolve{IP,UDP,TCP}Addr
Also fixes comments on ResolveIPAddr.

Fixes #4476.

R=bradfitz, golang-dev
CC=golang-dev
https://golang.org/cl/6854129
2012-12-01 14:49:54 +09:00
Anthony Martin
253ed02918 net: update docs and sync API for Plan 9
R=golang-dev, dave, mikioh.mikioh, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6674043
2012-11-30 11:41:50 -08:00
Shenghou Ma
9e30b708a1 all: set GOMAXPROCS to 1 when counting mallocs
also fix an annoying test that relies on $GOROOT be set.
Fixes #3690.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6844086
2012-12-01 00:38:01 +08:00
Dave Cheney
5b425cc3ab undo CL 6855110 / 869253ef7009
64bit atomics are broken on 32bit systems. This is issue 599.

linux/arm builders all broke with this change, I am concerned that the other 32bit builders are silently impacted.

««« original CL description
net: fix data races on deadline vars

Fixes #4434.

R=mikioh.mikioh, bradfitz, dvyukov, alex.brainman
CC=golang-dev
https://golang.org/cl/6855110
»»»

R=rsc, mikioh.mikioh, dvyukov, minux.ma
CC=golang-dev
https://golang.org/cl/6852105
2012-11-30 20:02:30 +11:00
Dave Cheney
be0d84e335 net: fix data races on deadline vars
Fixes #4434.

R=mikioh.mikioh, bradfitz, dvyukov, alex.brainman
CC=golang-dev
https://golang.org/cl/6855110
2012-11-30 18:26:51 +11:00
Dmitriy Vyukov
0ce96f9ef4 runtime: better stack traces in race reports
When a race happens inside of runtime (chan, slice, etc),
currently reports contain only user file:line.
If the line contains a complex expression,
it's difficult to figure out where the race exactly.
This change adds one more top frame with exact
runtime function (e.g. runtime.chansend, runtime.mapaccess).

R=golang-dev
CC=golang-dev
https://golang.org/cl/6851125
2012-11-30 10:29:41 +04:00
Alex Brainman
902af974cb os: check only user attributes in TestStatDirModeExec
Some have their system setup in a particular way,
see http://golang.org/issue/4444#c3.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6851129
2012-11-30 16:10:45 +11:00
Brad Fitzpatrick
9c2f410206 net/http: don't send chunked encoding on 204 responses
RFC 2616: "The 204 response MUST NOT include a message-body,
and thus is always terminated by the first empty line after
the header fields."

Previously we'd trigger chunked encoding by default on
responses, and then when finishing the request we'd write the
chunk trailers, which counted as a message-body.

Fixes #4454

R=golang-dev
CC=golang-dev
https://golang.org/cl/6782139
2012-11-29 18:00:51 -08:00
Russ Cox
6d622416f1 net: add test case for SplitHostPort with zone
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6854119
2012-11-29 15:43:05 -05:00
Robert Griesemer
521f11de6b exp/types: various missing checks for array/slice composite literals
- check indices of array/slice composite literals
- handle [...]T
- also: go/defer statements

R=rsc
CC=golang-dev
https://golang.org/cl/6856107
2012-11-29 09:57:37 -08:00
Robert Griesemer
305d7ada2b go/parser: permit [...]T where array types are permitted
More lenient parsing with better error recovery.
It's easier for the type check to pick up the slack.

R=iant
CC=golang-dev
https://golang.org/cl/6856108
2012-11-28 16:03:34 -08:00
Alex Brainman
5b65023563 os: include 0111 in directory file mode on windows
Fixes #4444.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6858079
2012-11-28 17:01:59 +11:00
Alex Brainman
16a5934540 exp/winfsnotify: fix data race in TestNotifyClose
Fixes #4342.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6850080
2012-11-28 17:01:22 +11:00
Alex Brainman
b5aa4789f9 net/http: fix broken TestIssue4191_InfiniteGetToPutTimeout
Test creates 2 tcp connections for put and get. Make sure
these are closed properly after test is over, otherwise
server hangs waiting for connection to be closed.

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/6842109
2012-11-28 17:00:50 +11:00
Dave Cheney
28b599425d net: move deadline logic into pollServer
Update #4434.

The proposal attempts to reduce the number of places where fd,{r,w}deadline is checked and updated in preparation for issue 4434. In doing so the deadline logic is simplified by letting the pollster return errTimeout from netFD.Wait{Read,Write} as part of the wakeup logic.

The behaviour of setting n = 0 has been restored to match rev 2a55e349097f, which was the previous change to fd_unix.go before CL 6851096.

R=jsing, bradfitz, mikioh.mikioh, rsc
CC=fullung, golang-dev
https://golang.org/cl/6850110
2012-11-28 11:29:25 +11:00
Mikio Hara
da803e5cd3 net: fix ResolveIPAddr
Fixes misedit in CL 6842053.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6849115
2012-11-28 08:45:23 +09:00
Dave Cheney
d244dd09f3 net: fix intermittent TestAddFDReturnsError failure
A fix similar to CL 6859043 was effective in resolving the intermittent failure.

Fixes #4423.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6854102
2012-11-28 10:08:59 +11:00
Mikio Hara
4f74bbd24c net: consoldate literal target address into IP address functions
This CL continues with introducing IPv6 scoped addressing capability
into the net package.

Update #4234.

R=rsc
CC=golang-dev
https://golang.org/cl/6842053
2012-11-28 06:36:05 +09:00
Robert Griesemer
e781b20ac9 go/format: Package format implements standard formatting of Go source.
Package format is a utility package that takes care of
parsing, sorting of imports, and formatting of .go source
using the canonical gofmt formatting parameters.

Use go/format in various clients instead of the lower-level components.

R=r, bradfitz, dave, rogpeppe, rsc
CC=golang-dev
https://golang.org/cl/6852075
2012-11-27 10:29:49 -08:00
Jan Ziak
51b8edcb37 runtime: use reflect·call() to enter the function gc()
Garbage collection code (to be merged later) is calling functions
which have many local variables. This increases the probability that
the stack capacity won't be big enough to hold the local variables.
So, start gc() on a bigger stack to eliminate a potentially large number
of calls to runtime·morestack().

R=rsc, remyoudompheng, dsymonds, minux.ma, iant, iant
CC=golang-dev
https://golang.org/cl/6846044
2012-11-27 13:04:59 -05:00
Dmitriy Vyukov
58ce93b6bf runtime/race: add test case for issue 4453
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6854103
2012-11-27 21:59:08 +04:00
Rick Arnold
94b3f6d728 regexp: add Split
As discussed in issue 2672 and on golang-nuts, this CL adds a Split() method
to regexp. It is based on returning the "opposite" of FindAllString() so that
the returned substrings are everything not matched by the expression.

See: https://groups.google.com/forum/?fromgroups=#!topic/golang-nuts/xodBZh9Lh2E

Fixes #2762.

R=remyoudompheng, r, rsc
CC=golang-dev
https://golang.org/cl/6846048
2012-11-27 12:58:27 -05:00
Volker Dobler
b46de71457 regexp: add examples
Update #4125

R=minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6847107
2012-11-27 10:33:15 -05:00
John Graham-Cumming
4228eb7915 log/syslog: correct message format
The syslog implementation was not correctly implementing the
traditional syslog format because it had a confused notion of
'priority'.  syslog priority is not a single number but is, in
fact, the combination of a facility number and a severity. The
previous Go syslog implementation had a single Priority that
appeared to be the syslog severity and no way of setting the
facility.  That meant that all syslog messages from Go
programs appeared to have a facility of 0 (LOG_KERN) which
meant they all appeared to come from the kernel.

Also, the 'prefix' was in fact the syslog tag (changed the
internal name for clarity as the term tag is more widely used)
and the timestamp and hostname values were missing from
messages.

With this change syslog messages are generated in the correct
format with facility and severity combined into a priority,
the timestamp in RFC3339 format, the hostname, the tag (with
the PID in [] appened) and the message.

The format is now:

   <PRI>1 TIMESTAMP HOSTNAME TAG[PID]: MSG

The TIMESTAMP, HOSTNAME and PID fields are filled in
automatically by the package. The TAG and the MSG are supplied
by the user. This is what rsyslogd calls TraditionalFormat and
should be compatible with multiple systems.

R=rsc, jgc, 0xjnml, mikioh.mikioh, bradfitz
CC=golang-dev
https://golang.org/cl/6782118
2012-11-27 10:21:43 -05:00
Dmitriy Vyukov
908e1b5ea1 runtime/race: add unit tests for race detector
R=golang-dev, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/6525052
2012-11-27 15:04:48 +04:00
Dmitriy Vyukov
d6fd52c088 net: fix flaky test
The test failed on one of the builders with:
timeout_test.go:594: 	ln.Accept: accept tcp 127.0.0.1:19373: use of closed network connection
http://build.golang.org/log/e83f4a152b37071b9d079096e15913811ad296b5

R=golang-dev, bradfitz, dave, mikioh.mikioh, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/6859043
2012-11-27 12:18:54 +04:00
Nigel Tao
478aff3d4d exp/cookiejar: new package.
This CL defines the API. Implementation will come in follow-up CLs.

Update #1960.

R=bradfitz, dr.volker.dobler, rsc
CC=golang-dev
https://golang.org/cl/6849092
2012-11-27 18:20:44 +11:00
Robert Griesemer
bb7c3c6803 go/ast: minor cleanup
It's better to use IsValid() then checking a (possibly
partially set up) position against NoPos directly.

R=dsymonds
CC=golang-dev
https://golang.org/cl/6855099
2012-11-26 17:17:49 -08:00
Anthony Martin
178c8578d5 os/user: update stub documentation
R=golang-dev, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/6844088
2012-11-26 16:02:08 -08:00
Anthony Martin
4ce3df5074 os: move Plan 9 directory marshaling code to syscall
The API additions to syscall are in dir_plan9.go.

R=seed, rsc, rminnich, mirtchovski, dave
CC=golang-dev, lucio.dere
https://golang.org/cl/6157045
2012-11-26 15:26:46 -08:00
Robert Griesemer
4a1b814668 go/printer: don't use 'infinity' value when it might lead to int32 overflow
Fixes 386 build breakage.

R=rsc
CC=golang-dev
https://golang.org/cl/6844091
2012-11-26 14:20:05 -08:00
Brad Fitzpatrick
127d2bf785 net/http: fix Transport races & deadlocks
Thanks to Dustin Sallings for exposing the most frustrating
bug ever, and for providing repro cases (which formed the
basis of the new tests in this CL), and to Dave Cheney and
Dmitry Vyukov for help debugging and fixing.

This CL depends on submited pollster CLs ffd1e075c260 (Unix)
and 14b544194509 (Windows), as well as unsubmitted 6852085.
Some operating systems (OpenBSD, NetBSD, ?) may still require
more pollster work, fixing races (Issue 4434 and
http://goo.gl/JXB6W).

Tested on linux-amd64 and darwin-amd64, both with GOMAXPROCS 1
and 4 (all combinations of which previously failed differently)

Fixes #4191
Update #4434 (related fallout from this bug)

R=dave, bradfitz, dsallings, rsc, fullung
CC=golang-dev
https://golang.org/cl/6851061
2012-11-26 13:31:02 -08:00
Robert Griesemer
9a61c0412c go/printer: some internal cleanups
Cleanups introduced originally by now abandoned
https://golang.org/cl/6846078/ .

Includes additional test cases for 'if' and 'for'
statements.

No formatting changes.

R=rsc
CC=golang-dev
https://golang.org/cl/6855096
2012-11-26 13:20:30 -08:00
Robert Griesemer
2a982e8e25 go/printer: Permit declaration and statement lists as input.
Also: Can set base indentation in printer.Config: all code
is going to be indented by at least that amount (except for
raw string literals spanning multiple lines, since their
values must not change).

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6847086
2012-11-26 13:14:04 -08:00
Robert Griesemer
d7b0271065 exp/types: fixed field/method lookup
also:

- composite literal checking close to complete
- cleaned up parameter, method, field checking
- don't let panics escape type checker
- more TODOs eliminated

R=rsc
CC=golang-dev
https://golang.org/cl/6816083
2012-11-26 12:49:04 -08:00
Anthony Martin
1de4d313dd crypto/tls: use 1/n-1 record splitting to protect against BEAST
This requires rebasing the block-mode test scripts.
I used GnuTLS version 3.1.4.

R=agl
CC=golang-dev
https://golang.org/cl/6844073
2012-11-26 10:56:39 -08:00
Dmitriy Vyukov
f4ed50c260 net: add deadline prolongation test
Currently the test exposes data races on deadline vars.

R=golang-dev, dave, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6845091
2012-11-26 22:28:39 +04:00
Shenghou Ma
2637777527 runtime: duplicate code for runtime.nanotime to avoid stack overflow in vDSO clock_gettime
Fixes #4402.

R=remyoudompheng, shivakumar.gn, random0x00, rsc
CC=golang-dev
https://golang.org/cl/6842063
2012-11-27 01:42:01 +08:00
Oling Cat
f80f23e748 runtime: re-format comments.
add necessary newlines.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6847067
2012-11-26 10:53:11 -05:00
Mikio Hara
e8cf49f701 net, cmd/fix: add IPv6 scoped addressing zone to INET, INET6 address structs
This CL starts to introduce IPv6 scoped addressing capability
into the net package.

The Public API changes are:
+pkg net, type IPAddr struct, Zone string
+pkg net, type IPNet struct, Zone string
+pkg net, type TCPAddr struct, Zone string
+pkg net, type UDPAddr struct, Zone string

Update #4234.

R=rsc, bradfitz, iant
CC=golang-dev
https://golang.org/cl/6849045
2012-11-27 00:45:42 +09:00
Mikio Hara
f02cf1997d runtime: regenerate defs-files for freebsd
R=minux.ma, jsing
CC=golang-dev
https://golang.org/cl/6855080
2012-11-26 21:29:13 +09:00
Shenghou Ma
62f54e1294 net/http: clarify docs of ParseForm and mention ParseForm in docs for FormValue
while we're at it, also fix a return value stutter in ParseForm.

R=bradfitz
CC=golang-dev
https://golang.org/cl/6847074
2012-11-26 20:03:24 +08:00
Joel Sing
4047f300c9 runtime: implement SysUnused for netbsd
R=golang-dev, bradfitz, minux.ma, dave
CC=golang-dev
https://golang.org/cl/6842081
2012-11-26 22:34:01 +11:00
Joel Sing
c6afb781e2 runtime: implement SysUnused for openbsd
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6854079
2012-11-26 22:32:59 +11:00
Dave Cheney
73b3e2301e net: never return -1 bytes read from netFD.Read
If the a network read would block, and a packet arrived just before the timeout expired, then the number of bytes from the previous (blocking) read, -1, would be returned.

This change restores the previous logic, where n would be unconditionally set to 0 if err != nil, but was skipped due to a change in CL 6851096.

The test for this change is CL 6851061.

R=bradfitz, mikioh.mikioh, dvyukov, rsc
CC=golang-dev
https://golang.org/cl/6852085
2012-11-26 10:59:43 +11:00
Brad Fitzpatrick
f97bb12bb0 net/http/httptest: protect against port reuse
Should make BSDs more reliable. (they seem to reuse ports
quicker than Linux)

Tested by hand with local modifications to force reuse on
Linux. (net/http tests failed before, pass now) Details in the
issue.

Fixes #4436

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6847101
2012-11-25 15:23:20 -08:00
Brad Fitzpatrick
c8fa7dcc25 bytes, strings: fix Reader WriteTo return value on 0 bytes copied
Fixes #4421

R=golang-dev, dave, minux.ma, mchaten, rsc
CC=golang-dev
https://golang.org/cl/6855083
2012-11-25 09:04:13 -08:00
Mikio Hara
1fbe3090d8 runtime: fix madvise for freebsd/amd64
Make use of carry clear condition instead of low or same.

R=minux.ma, jsing, dave
CC=golang-dev
https://golang.org/cl/6844080
2012-11-25 18:46:41 +09:00
Dmitriy Vyukov
74fcf82dd9 net: add unit tests for read/write deadlines
The tests verify that deadlines are "persistent",
read/write deadlines do not interfere, can be reset,
read deadline can be set with both SetDeadline()
and SetReadDeadline(), etc.

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/6850070
2012-11-25 13:27:32 +04:00
Dave Cheney
1e9ab9e792 time: add Now()/UnixNano() malloc tests
The fix for issue 4403 may include more calls to time.Now().UnixNano(). I was concerned that if this function allocated it would cause additional garbage on the heap. It turns out that it doesn't, which is a nice surprise.

Also add benchmark for Now().UnixNano()

R=bradfitz, minux.ma
CC=golang-dev
https://golang.org/cl/6849097
2012-11-25 11:29:06 +11:00
Alex Brainman
747dda9767 net: do not start io if deadline has passed
R=golang-dev, mikioh.mikioh, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/6851098
2012-11-25 10:02:57 +11:00
Caine Tighe
7afcae6bab http/transport.go: trivial comment error.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6856078
2012-11-25 05:08:17 +08:00
Brad Fitzpatrick
5fa3aeb14d net: check read and write deadlines before doing syscalls
Otherwise a fast sender or receiver can make sockets always
readable or writable, preventing deadline checks from ever
occuring.

Update #4191 (fixes it with other CL, coming separately)
Fixes #4403

R=golang-dev, alex.brainman, dave, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6851096
2012-11-23 22:15:26 -08:00
John Graham-Cumming
314fd62434 runtime: implement runtime.SysUnused on FreeBSD
madvise was missing so implement it in assembler. This change
needs to be extended to the other BSD variantes (Net and Open)

Without this change the scavenger will attempt to pass memory back
to the operating system when it has become idle, but the memory is
not returned and for long running Go processes the total memory used
can grow until OOM occurs.

I have only been able to test the code on FreeBSD AMD64. The ARM
platforms needs testing.

R=golang-dev, mikioh.mikioh, dave, jgc, minux.ma
CC=golang-dev
https://golang.org/cl/6850081
2012-11-24 15:55:19 +11:00
Dave Cheney
d4775a7814 net/http/httptest: fix possible race on historyListener.history
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6845077
2012-11-24 15:50:43 +11:00
Dave Cheney
dd43bf807d net/http: use runtime.Stack instead of runtime/debug.Stack
Fixes #4060.

2012/11/21 19:51:34 http: panic serving 127.0.0.1:47139: Kaaarn!
goroutine 7 [running]:
net/http.func·004(0x7f330807ffb0, 0x7f330807f100)
	/home/dfc/go/src/pkg/net/http/server.go:615 +0xa7
----- stack segment boundary -----
main.(*httpHandler).ServeHTTP()
	/home/dfc/src/httppanic.go:16 +0x53
net/http.(*conn).serve(0xc200090240, 0x0)
	/home/dfc/go/src/pkg/net/http/server.go:695 +0x55d
created by net/http.(*Server).Serve
	/home/dfc/go/src/pkg/net/http/server.go:1119 +0x36d

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6846085
2012-11-22 08:18:45 +11:00
Shenghou Ma
42c8904fe1 all: fix the the typos
Fixes #4420.

R=golang-dev, rsc, remyoudompheng
CC=golang-dev
https://golang.org/cl/6854080
2012-11-22 02:58:24 +08:00
Joel Sing
cd37fecffb runtime: update openbsd runtime to use new tfork syscall
Update OpenBSD runtime to use the new version of the sys___tfork
syscall and switch TLS initialisation from sys_arch to sys___set_tcb
(note that both of these syscalls are available in OpenBSD 5.2).

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6843058
2012-11-22 01:25:53 +11:00
Dave Cheney
d28133dc9f net: remove another unguarded sysfile == nil check
Putting aside the unguarded access to fd.sysfile, the condition will never be true as fd.incref above handles the closed condition.

R=mikioh.mikioh, dvyukov
CC=golang-dev
https://golang.org/cl/6845062
2012-11-21 15:04:22 +11:00
Shenghou Ma
7bce6f9386 net/http, net/http/httputil: fix TestChunkReaderAllocs failure when GOMAXPROCS > 1
R=fullung, bradfitz, dave
CC=golang-dev
https://golang.org/cl/6846081
2012-11-21 02:18:34 +08:00
Ian Lance Taylor
4bf261f9e3 exp/types: don't test importing types if using gccgo
The exp/types packages does not support the gccgo export data
format.  At some point it should, but not yet.

R=gri, bradfitz, r, iant, dsymonds
CC=golang-dev
https://golang.org/cl/6854068
2012-11-19 21:56:24 -08:00
Alex Brainman
54b9c20151 net/http/cgi: another attempt to fix windows tests
Also enables TestDirWindows test on windows.

Fixes #4401.

R=golang-dev, bradfitz
CC=golang-dev, krautz
https://golang.org/cl/6847072
2012-11-20 16:24:12 +11:00
Brad Fitzpatrick
9466c27fec net/http: remove more garbage from chunk reading
Noticed this while closing tabs. Yesterday I thought I could
ignore this garbage and hope that a fix for issue 2205 handled
it, but I just realized that's the opposite case,
string->[]byte, whereas this is []byte->string.  I'm having a
hard time convincing myself that an Issue 2205-style fix with
static analysis and faking a string header would be safe in
all cases without violating the memory model (callee assumes
frozen memory; are there non-racy ways it could keep being
modified?)

R=dsymonds
CC=dave, gobot, golang-dev
https://golang.org/cl/6850067
2012-11-19 19:50:42 -08:00
Brad Fitzpatrick
d32d1e098a mime/multipart: transparently decode quoted-printable transfer encoding
Fixes #4411

R=dsymonds
CC=gobot, golang-dev
https://golang.org/cl/6854067
2012-11-19 19:50:19 -08:00
Robert Griesemer
c00bda1352 go/printer: simply ignore filename changes in position information
There's no good reason to make any printer state adjustments
simply because the file name in node position information has
changed. Eliminate the relevant code.

R=r
CC=golang-dev
https://golang.org/cl/6856054
2012-11-19 13:23:32 -08:00
Brad Fitzpatrick
e070aeae77 net/http/cgi: more windows perl test work
Don't rely on finding cmd.exe in a particular spot.

Fixes #4401

R=golang-dev, krautz
CC=golang-dev
https://golang.org/cl/6842066
2012-11-19 10:40:13 -08:00
Christian Himpel
ca8aac698f runtime: gdb support: use parse_and_eval to get the goroutine id
This enables to loop over some goroutines, e.g. to print the
backtrace of goroutines 1 to 9:

        set $i = 1
        while $i < 10
        printf "backtrace of goroutine %d:\n", $i
        goroutine $i++ bt
        end

R=lvd, lvd
CC=golang-dev
https://golang.org/cl/6843071
2012-11-19 10:22:47 -08:00
Brad Fitzpatrick
c8e7469fcd net/http/cgi: make test more robust for Windows perl
Update #4401

R=golang-dev, mattn.jp
CC=golang-dev
https://golang.org/cl/6853067
2012-11-19 08:25:51 -08:00
Dave Cheney
c9856e7d22 net: fix data race on fd.sysfd
Fixes #4369.

Remove the check for fd.sysfd < 0, the first line of fd.accept() tests if the fd is open correctly and will handle the fd being closed during accept.

R=dvyukov, bradfitz
CC=golang-dev
https://golang.org/cl/6843076
2012-11-19 06:53:58 +11:00
Dave Cheney
0bfece06d7 net: remove unused nil check
This is part 1 of a series of proposals to fix issue 4369.

In resolving issue 3507 it was decided not to nil out the inner conn.fd field to avoid a race. This implies the checks for fd == nil inside incref/decref are never true.

Removing this logic removes one source of errClosing error values, which affects issue 4373 and moves towards bradfitz's request that fd.accept() return io.EOF when closed concurrently.

Update #4369.
Update #4373.

R=mikioh.mikioh, bradfitz, dvyukov, rsc
CC=golang-dev
https://golang.org/cl/6852057
2012-11-18 15:31:26 +11:00
Dave Cheney
4758f89ddb runtime/cgo: enable warnings and treat as errors
Enable warnings as errors during the cgo portion of runtime/cgo. iant requested that the list of flags match cmd/dist/build.c, but I would like to avoid the set of disabled warnings if possible.

ref: https://groups.google.com/d/topic/golang-nuts/TrCoVzIIG4M/discussion

requires: 6843061

R=minux.ma, iant
CC=golang-dev
https://golang.org/cl/6852055
2012-11-18 08:58:54 +11:00
Shenghou Ma
d1e06dab7c runtime: don't assume AT_RANDOM provide 4-byte aligned ptr
R=dave, remyoudompheng
CC=golang-dev
https://golang.org/cl/6854056
2012-11-18 02:47:17 +08:00
Robert Griesemer
80dcc434a8 go/doc: fix identifier blank import handling for examples
Replacement CL for 6813061; thanks to minux for prototyping.

Fixes #4300.

R=minux.ma
CC=golang-dev
https://golang.org/cl/6782082
2012-11-17 10:40:11 -08:00
Shenghou Ma
38458ce3fe crypto/md5: speed up aligned writes and test/bench unaligned writes
Write() can safely use uint32 loads when input is aligned.
Also add test and benchmarks for unaligned writes.

Benchmark result obtained by Dave Cheney on ARMv5TE @ 1.2GHz:
benchmark                       old ns/op    new ns/op    delta
BenchmarkHash8Bytes                  4104         3417  -16.74%
BenchmarkHash1K                     22061        11208  -49.20%
BenchmarkHash8K                    146630        65148  -55.57%
BenchmarkHash8BytesUnaligned         4128         3436  -16.76%
BenchmarkHash1KUnaligned            22054        21473   -2.63%
BenchmarkHash8KUnaligned           146658       146909   +0.17%

benchmark                        old MB/s     new MB/s  speedup
BenchmarkHash8Bytes                  1.95         2.34    1.20x
BenchmarkHash1K                     46.42        91.36    1.97x
BenchmarkHash8K                     55.87       125.74    2.25x
BenchmarkHash8BytesUnaligned         1.94         2.33    1.20x
BenchmarkHash1KUnaligned            46.43        47.69    1.03x
BenchmarkHash8KUnaligned            55.86        55.76    1.00x

R=golang-dev, dave, bradfitz
CC=golang-dev
https://golang.org/cl/6782072
2012-11-18 02:23:34 +08:00
Shenghou Ma
3513d84068 runtime/cgo: fix compilation on Windows with CFLAGS -Wall -Werror
also fix one out-of-date comment in cmd/ld/pe.c as well.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/6843061
2012-11-18 02:06:08 +08:00
Dave Cheney
7ec76e25b6 archive/zip: handle extra data headers with no body
Fixes #4393.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6854058
2012-11-18 00:45:47 +11:00
Robin Eklind
4f250132f7 archive/zip, crypto/tls, net/http: Fix print format errors.
All of the errors were located using "go vet ./..." in "src/pkg".

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6856056
2012-11-16 17:24:43 -08:00
Brad Fitzpatrick
f3e6b20606 net/http: reduce allocations in chunk reading & writing
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6847063
2012-11-16 13:25:01 -08:00
Robert Griesemer
de58eb9091 go/printer: leave indentation alone when printing nodes from different files
ASTs may be created by various tools and built from nodes of
different files. An incorrectly constructed AST will likely
not print at all, but a (structurally) correct AST with bad
position information should still print structurally correct.

One heuristic used was to reset indentation when the filename
in the position information of nodes changed. However, this
can lead to wrong indentation for structurally correct ASTs.

Fix: Don't change the indentation in this case.

Related to issue 4300.

R=r
CC=golang-dev
https://golang.org/cl/6849066
2012-11-16 13:17:12 -08:00
Robert Griesemer
a42e8a8086 go/ast: FuncType.Params may be nil (per AST documentation)
ast.Walk needs to check for it or it will crash.

R=r
CC=golang-dev
https://golang.org/cl/6852062
2012-11-16 11:53:26 -08:00
Dmitriy Vyukov
8f82bff545 runtime: hide mheap from race detector
This significantly decreases amount of shadow memory
mapped by race detector.
I haven't tested on Windows, but on Linux it reduces
virtual memory size from 1351m to 330m for fmt.test.
Fixes #4379.

R=golang-dev, alex.brainman, iant
CC=golang-dev
https://golang.org/cl/6849057
2012-11-16 20:06:11 +04:00
Oling Cat
aa3d05acc9 runtime: remove extra parentheses.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6843069
2012-11-16 23:09:37 +11:00
Joel Sing
aaf3b71288 crypto/tls: add support for loading EC X.509 key pairs
Add support for loading X.509 key pairs that consist of a certificate
with an EC public key and its corresponding EC private key.

R=agl
CC=golang-dev
https://golang.org/cl/6776043
2012-11-16 19:33:59 +11:00
Dmitriy Vyukov
9b4aaa418f syscall: fix data races in LazyDLL/LazyProc
Reincarnation of https://golang.org/cl/6817086 (sent from another account).
It is ugly because sync.Once will cause allocation of a closure.
Fixes #4343.

R=golang-dev, bradfitz, alex.brainman
CC=golang-dev
https://golang.org/cl/6856046
2012-11-16 12:06:48 +04:00
Marcel van Lohuizen
8b7ea6489c exp/locale/collate: changed implementation of Compare and CompareString to
compare incrementally. Also modified collation API to be more high-level
by removing the need for an explicit buffer to be passed as an argument.
This considerably speeds up Compare and CompareString.  This change also eliminates
the need to reinitialize the normalization buffer for each use of an iter. This
also significantly improves performance for Key and KeyString.

R=r, rsc
CC=golang-dev
https://golang.org/cl/6842050
2012-11-15 22:23:56 +01:00
Brad Fitzpatrick
0d0eff7165 os: add FileMode.IsRegular
API change.

R=golang-dev, r, iant, rsc
CC=golang-dev
https://golang.org/cl/6844048
2012-11-15 11:46:00 -08:00
Dmitriy Vyukov
27087022ce sync/atomic: fix race instrumentation
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6782075
2012-11-15 21:30:24 +04:00
Ian Lance Taylor
cc8bd8969f runtime/cgo: include <string.h> as needed so that strerror is declared
R=golang-dev, dave, jsing
CC=golang-dev
https://golang.org/cl/6847051
2012-11-14 22:04:03 -08:00
Robin Eklind
45b4867d0e strconv: Removed unnecessary use of goto. Made code easier to read.
R=gri
CC=gobot, golang-dev
https://golang.org/cl/6855048
2012-11-14 09:42:48 -08:00
Joel Sing
63315c0af1 crypto/x509: add support for SEC1/EC private keys.
Add support for parsing SEC1 EC private keys and PKCS8 encapsulated
EC private key structures.

R=agl
CC=golang-dev
https://golang.org/cl/6767045
2012-11-15 03:39:00 +11:00
Joel Sing
8c96e6d740 debug/elf: fix offset for GNU version symbols
Since we no longer skip the first entry when reading a symbol table,
we no longer need to allow for the offset difference when processing
the GNU version symbols.

Unbreaks builds on Linux.

R=golang-dev, agl, iant
CC=golang-dev
https://golang.org/cl/6843057
2012-11-15 03:36:19 +11:00
Joel Sing
76689845e3 debug/elf: do not skip first symbol in the symbol table
Do not skip the first symbol in the symbol table. Any other indexes
into the symbol table (for example, indexes in relocation entries)
will now refer to the symbol following the one that was intended.

Add an object that contains debug relocations, which debug/dwarf
failed to decode correctly. Extend the relocation tests to cover
this case.

Note that the existing tests passed since the symbol following the
symbol that required relocation is also of type STT_SECTION.

Fixes #4107.

R=golang-dev, mikioh.mikioh, iant, iant
CC=golang-dev
https://golang.org/cl/6848044
2012-11-15 02:24:14 +11:00
Dmitriy Vyukov
063c13a34c runtime/race: more precise handling of finalizers
Currently race detector runtime just disables race detection in the finalizer goroutine.
It has false positives when a finalizer writes to shared memory -- the race with finalizer is reported in a normal goroutine that accesses the same memory.
After this change I am going to synchronize the finalizer goroutine with the rest of the world in racefingo(). This is closer to what happens in reality and so
does not have false positives.
And also add README file with instructions how to build the runtime.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6810095
2012-11-14 16:58:10 +04:00
Dmitriy Vyukov
51e89f59b2 runtime: add RaceRead/RaceWrite functions
It allows to catch e.g. a data race between atomic write and non-atomic write,
or Mutex.Lock() and mutex overwrite (e.g. mu = Mutex{}).

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6817103
2012-11-14 16:51:23 +04:00
Andrew Gerrand
e33b9f7815 regexp: add simple package-level example
Update #4125

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6846045
2012-11-14 10:43:21 +01:00
Joel Sing
7f70bb5913 syscall: regenerate z-files for openbsd/386
Regenerate z-files for OpenBSD/386 on OpenBSD 5.2.

R=golang-dev, bradfitz, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6844044
2012-11-14 19:06:12 +11:00
Brad Fitzpatrick
56bcef02fc net/http: add missing error checking reading trailers
This is a simplified version of earlier versions of this CL
and now only fixes obviously incorrect things, without
changing the locking on bodyEOFReader.

I'd like to see if this is sufficient before changing the
locking.

Update #4191

R=golang-dev, rsc, dave
CC=golang-dev
https://golang.org/cl/6739055
2012-11-13 22:38:25 -08:00
Robert Griesemer
aa38801788 reflect: fix FieldByNameFunc
The existing algorithm did not properly propagate the type
count from one level to the next, and as a consequence it
missed collisions.

Properly propagate multiplicity (count) information to the
next level.

benchmark                old ns/op    new ns/op    delta
BenchmarkFieldByName1          182          180   -1.10%
BenchmarkFieldByName2         6273         6183   -1.43%
BenchmarkFieldByName3        49267        46784   -5.04%

Fixes #4355.

R=rsc
CC=golang-dev
https://golang.org/cl/6821094
2012-11-13 10:45:30 -08:00
Russ Cox
1120982590 reflect: add ArrayOf, ChanOf, MapOf, SliceOf
In order to add these, we need to be able to find references
to such types that already exist in the binary. To do that, introduce
a new linker section holding a list of the types corresponding to
arrays, chans, maps, and slices.

To offset the storage cost of this list, and to simplify the code,
remove the interface{} header from the representation of a
runtime type. It was used in early versions of the code but was
made obsolete by the kind field: a switch on kind is more efficient
than a type switch.

In the godoc binary, removing the interface{} header cuts two
words from each of about 10,000 types. Adding back the list of pointers
to array, chan, map, and slice types reintroduces one word for
each of about 500 types. On a 64-bit machine, then, this CL *removes*
a net 156 kB of read-only data from the binary.

This CL does not include the needed support for precise garbage
collection. I have created issue 4375 to track that.

This CL also does not set the 'algorithm' - specifically the equality
and copy functions - for a new array correctly, so I have unexported
ArrayOf for now. That is also part of issue 4375.

Fixes #2339.

R=r, remyoudompheng, mirtchovski, iant
CC=golang-dev
https://golang.org/cl/6572043
2012-11-13 13:06:29 -05:00
Russ Cox
9799a5a4fd runtime: allow up to 128 GB of allocated memory
Incorporates code from CL 6828055.

Fixes #2142.

R=golang-dev, iant, devon.odell
CC=golang-dev
https://golang.org/cl/6826088
2012-11-13 12:45:08 -05:00
Joel Sing
fc5e64cb8f syscall: regenerate z-files for openbsd/amd64
Regenerate z-files for OpenBSD/amd64 on OpenBSD 5.2.

R=golang-dev, bradfitz, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6843045
2012-11-14 03:19:34 +11:00
Mikio Hara
306afc7725 net: consolidate common socket functions for Plan 9
This CL extends changeset 13126:fc4a62e14aba to Plan 9.

R=ality, golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6820124
2012-11-13 16:18:37 +09:00
Mikio Hara
677c6e6ee7 net: protocol specific listen functions return a proper local socket address
When a nil listener address is passed to some protocol specific
listen function, it will create an unnamed, unbound socket because
of the nil listener address. Other listener functions may return
invalid address error.

This CL allows to pass a nil listener address to all protocol
specific listen functions to fix above inconsistency. Also make it
possible to return a proper local socket address in case of a nil
listner address.

Fixes #4190.
Fixes #3847.

R=rsc, iant
CC=golang-dev
https://golang.org/cl/6525048
2012-11-13 12:56:28 +09:00
Mikio Hara
0ae80785e6 net: make LocalAddr on multicast UDPConn return a listening address
The package go.net/ipv4 allows to exist a single UDP listener
that join multiple different group addresses. That means that
LocalAddr on multicast UDPConn returns a first joined group
address is not desirable.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6822108
2012-11-13 12:26:20 +09:00
Jeff R. Allen
7e7b89f7d0 net/textproto: faster header canonicalization with fewer allocations
By keeping a single copy of the strings that commonly show up
in headers, we can avoid one string allocation per header.

benchmark                  old ns/op    new ns/op    delta
BenchmarkReadMIMEHeader        19590        10824  -44.75%
BenchmarkUncommon               3168         1861  -41.26%

benchmark                 old allocs   new allocs    delta
BenchmarkReadMIMEHeader           32           25  -21.88%
BenchmarkUncommon                  5            5    0.00%

R=bradfitz, golang-dev, dave, rsc, jra
CC=golang-dev
https://golang.org/cl/6721055
2012-11-12 15:31:42 -08:00
Brad Fitzpatrick
73c67606e9 net/http: handle 413 responses more robustly
When HTTP bodies were too large and we didn't want to finish
reading them for DoS reasons, we previously found it necessary
to send a FIN and then pause before closing the connection
(which might send a RST) if we wanted the client to have a
better chance at receiving our error response. That was Issue 3595.

This issue adds the same fix to request headers which
are too large, which might fix the Windows flakiness
we observed on TestRequestLimit at:
http://build.golang.org/log/146a2a7d9b24441dc14602a1293918191d4e75f1

R=golang-dev, alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/6826084
2012-11-12 15:20:18 -08:00
David Symonds
80f4ff226f exp/types: avoid init race in check_test.go.
There was an init race between
	check_test.go:init
        universe.go:def
        use of Universe
and
	universe.go:init
        creation of Universe

The order in which init funcs are executed in a package is unspecified.
The test is not currently broken in the golang.org environment
because the go tool compiles the test with non-test sources before test sources,
but other environments may, say, sort the source files before compiling,
and thus trigger this race, causing a nil pointer panic.

R=gri
CC=golang-dev
https://golang.org/cl/6827076
2012-11-13 09:08:33 +11:00
Rick Arnold
c90739e41e encoding/json: skip unexpected null values
As discussed in issue 2540, nulls are allowed for any type in JSON so they should not result in an error during Unmarshal.
Fixes #2540.

R=rsc
CC=golang-dev
https://golang.org/cl/6759043
2012-11-12 15:35:11 -05:00
Roger Peppe
791fb978dd crypto/x509: implement EncryptPEMBlock
Arbitrary decisions: order of the arguments and the
fact it takes a block-type argument (rather than
leaving to user to fill it in later); I'm happy whatever
colour we want to paint it.

We also change DecryptPEMBlock so that it won't
panic when the IV has the wrong size.

R=agl, agl
CC=golang-dev
https://golang.org/cl/6820114
2012-11-12 15:31:23 +00:00
Roger Peppe
1e1733a9ac encoding/pem: write Proc-Type header first.
See RFC 1421, section 4.6.1.1

R=agl, agl
CC=golang-dev
https://golang.org/cl/6814104
2012-11-12 15:29:17 +00:00
David McLeish
20a1815833 archive/zip: Fix bounds check panic for ZIP files with a truncated extra header.
R=adg, dave
CC=gobot, golang-dev
https://golang.org/cl/6811080
2012-11-12 12:21:00 +01:00
Ian Lance Taylor
e9a3087e29 runtime, runtime/cgo: track memory allocated by non-Go code
Otherwise a poorly timed GC can collect the memory before it
is returned to the Go program.

R=golang-dev, dave, dvyukov, minux.ma
CC=golang-dev
https://golang.org/cl/6819119
2012-11-10 11:19:06 -08:00
Mikio Hara
5612edb13e net: add more tests for protocol specific methods
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6821100
2012-11-10 14:34:34 +09:00
Ian Lance Taylor
5e57954f8c runtime/pprof: fix typo in comment
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6810102
2012-11-08 23:48:13 -08:00
Shenghou Ma
4022fc4e21 runtime: use vDSO clock_gettime for time.now & runtime.nanotime on Linux/amd64
Performance improvement aside, time.Now() now gets real nanosecond resolution
on supported systems.

Benchmark done on Core i7-2600 @ 3.40GHz with kernel 3.5.2-gentoo.
original vDSO gettimeofday:
BenchmarkNow    100000000               27.4 ns/op
new vDSO gettimeofday fallback:
BenchmarkNow    100000000               27.6 ns/op
new vDSO clock_gettime:
BenchmarkNow    100000000               24.4 ns/op

R=golang-dev, bradfitz, iant, iant
CC=golang-dev
https://golang.org/cl/6814103
2012-11-09 14:19:07 +08:00
Mikio Hara
f668e0a5b3 net: consolidate multiple init functions
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6819117
2012-11-09 12:09:22 +09:00
Mikio Hara
e245ae7501 runtime: re-enable crash test on FreeBSD
It also passes on FreeBSD.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6812103
2012-11-09 10:05:46 +09:00
David Symonds
86b9e3e2b4 archive/tar: accept binary format when reading numeric header fields.
Fixes #4358.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6840043
2012-11-09 08:50:10 +11:00
Mikio Hara
5451708d5b net: fix non-unixen build
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6813101
2012-11-09 02:09:09 +09:00
Joel Sing
4e75d2c7d5 runtime: re-enable crash test on NetBSD
Re-enable the crash tests on NetBSD now that the issue has been
identified and fixed.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6813100
2012-11-09 03:41:43 +11:00
Dmitriy Vyukov
3f7f030c59 runtime: fix instrumentation of slice append for race detection
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6819107
2012-11-08 20:37:05 +04:00
Brad Fitzpatrick
ef6806fb13 net: close fds eagerly in DialTimeout
Integrates with the pollserver now.

Uses the old implementation on windows and plan9.

Fixes #2631

R=paul, iant, adg, bendaglish, rsc
CC=golang-dev
https://golang.org/cl/6815049
2012-11-08 10:35:16 -06:00
Shenghou Ma
48b739caac time: clarify why timer.Stop and ticker.Stop don't close the channel
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6818106
2012-11-08 23:25:48 +08:00
Anthony Martin
024a92c1da runtime: use vDSO for gettimeofday on linux/amd64
Intel Core 2 Duo (2.16 GHz) running 3.6.5-1-ARCH

benchmark       old ns/op    new ns/op    delta
BenchmarkNow         1856         1034  -44.29%

R=rsc
CC=golang-dev
https://golang.org/cl/6826072
2012-11-07 18:29:31 -08:00
Nigel Tao
64b3e590c0 image/jpeg: handle fill bytes.
Fixes #4337.

R=r, minux.ma
CC=golang-dev
https://golang.org/cl/6814098
2012-11-08 10:36:29 +11:00
David Symonds
0ac317817b archive/tar: avoid writing ModTime that is out of range.
Update #4358
Still to do: support binary numeric format in Reader.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6818101
2012-11-08 08:22:40 +11:00
Rémy Oudompheng
f59a605645 runtime: use runtime·callers when racefuncenter's pc is on the heap.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6821069
2012-11-07 21:35:21 +01:00
Dmitriy Vyukov
1ebf2d85ba runtime/race: add Windows support
This is copy of https://golang.org/cl/6810080
but sent from another account (dvyukov@gmail.com is not in CONTRIBUTORS).

R=rsc
CC=golang-dev
https://golang.org/cl/6827060
2012-11-07 23:59:09 +04:00
Ian Lance Taylor
f8614a6645 reflect: fix test of whether structs are identical
The old code worked with gc, I assume because the linker
unified identical strings, but it failed with gccgo.

R=rsc
CC=gobot, golang-dev
https://golang.org/cl/6826063
2012-11-07 11:55:35 -08:00
Roger Peppe
768ba46cc1 crypto/x509: fix DecryptPEMBlock
The current implement can fail when the
block size is not a multiple of 8 bytes.
This CL makes it work, and also checks that the
data is in fact a multiple of the block size.

R=agl, agl
CC=golang-dev
https://golang.org/cl/6827058
2012-11-07 15:16:34 +00:00
Russ Cox
cb856adea9 cmd/gc: annotate local variables with unique ids for inlining
Avoids problems with local declarations shadowing other names.
We write a more explicit form than the incoming program, so there
may be additional type annotations. For example:

        int := "hello"
        j := 2

would normally turn into

        var int string = "hello"
        var j int = 2

but the int variable shadows the int type in the second line.

This CL marks all local variables with a per-function sequence number,
so that this would instead be:

        var int·1 string = "hello"
        var j·2 int = 2

Fixes #4326.

R=ken2
CC=golang-dev
https://golang.org/cl/6816100
2012-11-07 09:59:19 -05:00
Mikio Hara
63f29d17d1 net: fix protocol number for IPv6 test
The protocol number of ICMP for IPv6 is 58, not 1.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6810093
2012-11-07 21:55:29 +09:00
Dmitriy Vyukov
1a19f01a68 runtime/race: lazily allocate shadow memory
Currently race detector runtime maps shadow memory eagerly at process startup.
It works poorly on Windows, because Windows requires reservation in swap file
(especially problematic if several Go program runs at the same, each consuming GBs
of memory).
With this change race detector maps shadow memory lazily, so Go runtime must notify
about all new heap memory.
It will help with Windows port, but also eliminates scary 16TB virtual mememory
consumption in top output (which sometimes confuses some monitoring scripts).

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6811085
2012-11-07 12:48:58 +04:00
Alex Brainman
eb2e6e59ee net: implement IPv6 support for windows
Thank you zhoumichaely for original CL 5175042.

Fixes #1740.
Fixes #2315.

R=golang-dev, bradfitz, mikioh.mikioh
CC=golang-dev, zhoumichaely
https://golang.org/cl/6822045
2012-11-07 16:58:20 +11:00
Carl Mastrangelo
f8892fb395 crypto/sha1: Make sha-1 do block mixup in place
Benchmarks:

benchmark              old ns/op    new ns/op    delta
BenchmarkHash8Bytes          762          674  -11.55%
BenchmarkHash1K             8791         7375  -16.11%
BenchmarkHash8K            65094        54881  -15.69%

benchmark               old MB/s     new MB/s  speedup
BenchmarkHash8Bytes        10.50        11.86    1.13x
BenchmarkHash1K           116.48       138.84    1.19x
BenchmarkHash8K           125.85       149.27    1.19x

R=dave, rsc, iant
CC=golang-dev
https://golang.org/cl/6820096
2012-11-07 13:41:02 +11:00
Shenghou Ma
882eb608b1 sort: fix comment for various Search routines
Fixes #4205 (again).

R=r, 0xjnml
CC=golang-dev
https://golang.org/cl/6819082
2012-11-07 05:07:46 +08:00
Shenghou Ma
0e3f4fdb52 net/rpc: give hint to pass a pointer to Register
Fixes #4325.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6819081
2012-11-07 05:03:16 +08:00
Daniel Morsing
d098bffd84 cmd/gc, runtime: avoid unnecessary copy on type assertion.
When the first result of a type assertion is blank, the compiler would still copy out a potentially large non-interface type.

Fixes #1021.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6812079
2012-11-06 20:40:40 +01:00
Dmitriy Vyukov
0ead18c59e runtime: mark race instrumentation callbacks as nosplitstack
It speedups the race detector somewhat, but also prevents
getcallerpc() from obtaining lessstack().

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6812091
2012-11-06 20:54:22 +04:00
Dmitriy Vyukov
6ae448e8df runtime: fix deadlock in parallel for test
The deadlock occurs when another goroutine requests GC
during the test. When wait=true the test expects physical parallelism,
that is, that P goroutines are all active at the same time.
If GC is requested, then part of the goroutines are not scheduled,
so other goroutines deadlock.
With wait=false, goroutines finish parallel for w/o waiting for all
other goroutines.
Fixes #3954.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6820098
2012-11-06 20:11:16 +04:00
Dmitriy Vyukov
d6b9a03b7f runtime: disable parallel for tests under race detector.
The race detector does not understand ParFor synchronization, because it's implemented in C.
If run with -cpu=2 currently race detector says:
 WARNING: DATA RACE
 Read by goroutine 5:
  runtime_test.TestParForParallel()
      src/pkg/runtime/parfor_test.go:118 +0x2e0
  testing.tRunner()
      src/pkg/testing/testing.go:301 +0x8f
 Previous write by goroutine 6:
  runtime_test.func·024()
      src/pkg/runtime/parfor_test.go:111 +0x52

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6811082
2012-11-06 12:09:40 +04:00
Shenghou Ma
834028d527 net: fix timeout slack calculation
R=alex.brainman
CC=golang-dev
https://golang.org/cl/6816085
2012-11-04 18:07:59 +08:00
Alex Brainman
a906f9aa86 net: do not test TestReadWriteDeadline timeout upper bound during short test
It also increases timeout deltas to allow for longer wait.
Also disables this test on plan9.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6821062
2012-11-04 12:41:49 +11:00
Rob Pike
20548b153f sort: make return value for 'not found' clearer in docs
It was well-defined but easy to miss that the return value for
"not found" is len(input) not -1 as many expect.

Fixes #4205.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6820080
2012-11-02 16:17:34 -07:00
Dmitriy Vyukov
600de1fb3d net/http: fix data race in test
The issue is that server still sends body,
when client closes the fd.
Fixes #4329.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6822072
2012-11-03 00:26:36 +04:00
Shenghou Ma
31f8b07e55 runtime/cgo, go/build: cgo support for FreeBSD/ARM
This is the last CL for FreeBSD/ARM support.
Also update cmd/ld/doc.go for 5l support of -Hfreebsd.

R=rsc
CC=golang-dev
https://golang.org/cl/6650051
2012-11-03 02:22:37 +08:00
Alex Brainman
90d959be78 net: add missing locking in windows Shutdown
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6811069
2012-11-02 20:46:47 +11:00
Nigel Tao
d659633aff image/png: update palette out-of-bounds comment.
R=r
CC=golang-dev
https://golang.org/cl/6817070
2012-11-02 17:20:19 +11:00
Alex Brainman
84e20465fc net: use better error messages on windows
Fixes #4320.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6810064
2012-11-02 11:07:22 +11:00
Robert Griesemer
048323aa12 go/ast: document use of Data field for method objects
R=iant
CC=golang-dev
https://golang.org/cl/6775093
2012-11-01 16:27:43 -07:00
Robert Griesemer
159302f36f exp/types: move exp/types/staging -> exp/types
- removes exp/types/staging
- the only code change is in exp/gotype/gotype.go

R=iant
CC=golang-dev
https://golang.org/cl/6822068
2012-11-01 15:38:17 -07:00
Robert Griesemer
98133ac03a exp/types, exp/gotype: remove exp/types
The only code change is in exp/gotype/gotype.go.
The latest reviewed version of exp/types is now
exp/types/staging.

First step toward replacing exp/types with
exp/types/staging.

R=iant
CC=golang-dev
https://golang.org/cl/6819071
2012-11-01 15:25:51 -07:00
Eric Roshan-Eisner
03c52a5d65 crypto: use better hash benchmarks
Labels the existing benchmark as stream, and add benchmarks that
compute the checksum.

R=golang-dev, agl
CC=golang-dev
https://golang.org/cl/6814060
2012-11-01 16:21:18 -04:00
Rémy Oudompheng
824b332652 net: fix race in TestReadWriteDeadline.
Discovered by adding OBLOCK support to race
instrumentation.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6819067
2012-11-01 20:52:30 +01:00
Robert Griesemer
27c990e794 encoding/binary: skip blank fields when (en/de)coding structs
- minor unrelated cleanups
- performance impact in the noise

benchmark                       old ns/op    new ns/op    delta
BenchmarkReadSlice1000Int32s        83462        83346   -0.14%
BenchmarkReadStruct                  4141         4247   +2.56%
BenchmarkReadInts                    1588         1586   -0.13%
BenchmarkWriteInts                   1550         1489   -3.94%
BenchmarkPutUvarint32                  39           39   +1.02%
BenchmarkPutUvarint64                 142          144   +1.41%

benchmark                        old MB/s     new MB/s  speedup
BenchmarkReadSlice1000Int32s        47.93        47.99    1.00x
BenchmarkReadStruct                 16.90        16.48    0.98x
BenchmarkReadInts                   18.89        18.91    1.00x
BenchmarkWriteInts                  19.35        20.15    1.04x
BenchmarkPutUvarint32              101.90       100.82    0.99x
BenchmarkPutUvarint64               56.11        55.45    0.99x

Fixes #4185.

R=r, rsc
CC=golang-dev
https://golang.org/cl/6750053
2012-11-01 12:39:20 -07:00
Han-Wen Nienhuys
4094c1bae7 syscall: add {Get,Set,List,Remove}xattr on Linux.
R=golang-dev, minux.ma, fullung, dave, rsc, hanwenn
CC=golang-dev
https://golang.org/cl/6350074
2012-11-01 14:49:38 -04:00
Rémy Oudompheng
ce287933d6 cmd/gc, runtime: pass PC directly to racefuncenter.
go test -race -run none -bench . encoding/json
benchmark                      old ns/op    new ns/op    delta
BenchmarkCodeEncoder          3207689000   1716149000  -46.50%
BenchmarkCodeMarshal          3206761000   1715677000  -46.50%
BenchmarkCodeDecoder          8647304000   4482709000  -48.16%
BenchmarkCodeUnmarshal        8032217000   3451248000  -57.03%
BenchmarkCodeUnmarshalReuse   8016722000   3480502000  -56.58%
BenchmarkSkipValue           10340453000   4560313000  -55.90%

benchmark                       old MB/s     new MB/s  speedup
BenchmarkCodeEncoder                0.60         1.13    1.88x
BenchmarkCodeMarshal                0.61         1.13    1.85x
BenchmarkCodeDecoder                0.22         0.43    1.95x
BenchmarkCodeUnmarshal              0.24         0.56    2.33x
BenchmarkCodeUnmarshalReuse         0.24         0.56    2.33x
BenchmarkSkipValue                  0.19         0.44    2.32x

Fixes #4248.

R=dvyukov, golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6815066
2012-11-01 19:43:29 +01:00
Robert Griesemer
5d15963a1f exp/types/staging: filling in more blanks
- simplified assignment checking by removing duplicate code
- implemented field lookup (methods, structs, embedded fields)
- importing methods (not just parsing them)
- type-checking functions and methods
- typechecking more statements (inc/dec, select, return)
- tracing support for easier debugging
- handling nil more correctly (comparisons)
- initial support for [...]T{} arrays
- initial support for method expressions
- lots of bug fixes

All packages under pkg/go as well as pkg/exp/types typecheck
now with pkg/exp/gotype applied to them; i.e., a significant
amount of typechecking works now (several statements are not
implemented yet, but handling statements is almost trivial in
comparison with typechecking expressions).

R=rsc
CC=golang-dev
https://golang.org/cl/6768063
2012-11-01 11:23:27 -07:00
Ian Lance Taylor
f07f9de8ec go/build: support compiler as build constraint
This supports writing different .c/.s code when using gccgo.

R=golang-dev, dsymonds, iant, rsc
CC=golang-dev
https://golang.org/cl/6823055
2012-11-01 11:12:15 -07:00
Ryan Hitchman
c7873ff2a6 compress/flate: shrink decompressor struct for better performance
Helps with issue 2703.

R=dave, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/5536078
2012-11-01 13:57:24 -04:00
Jan Ziak
5c1422afab runtime: move Itab to runtime.h
The 'type' field of Itab will be used by the garbage collector.

R=rsc
CC=golang-dev
https://golang.org/cl/6815059
2012-11-01 13:13:20 -04:00
Alexey Borzenkov
1eae1252e9 net: fix a bad cast in dnsmsg.go
Incorrect cast was causing panics when
calling String() on dnsMsg with dnsRR_A
answers.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6818043
2012-11-01 12:57:44 -04:00
Jan Ziak
e0c9d04aec runtime: add memorydump() debugging function
R=golang-dev
CC=golang-dev, remyoudompheng, rsc
https://golang.org/cl/6780059
2012-11-01 12:56:25 -04:00
Mikio Hara
b602c3dbbd all: clear execute bit
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6826044
2012-11-01 10:04:42 +09:00
Nigel Tao
de6bf20496 image/png: degrade gracefully for palette index values that aren't
defined by the PLTE chunk. Such pixels decode to opaque black,
which matches what libpng does.

Fixes #4319.

On my reading, the PNG spec isn't clear whether palette index values
outside of those defined by the PLTE chunk is an error, and if not,
what to do.

Libpng 1.5.3 falls back to opaque black. png_set_PLTE says:

/* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead
 * of num_palette entries, in case of an invalid PNG file that has
 * too-large sample values.
 */
png_ptr->palette = (png_colorp)png_calloc(png_ptr,
        PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color));

ImageMagick 6.5.7 returns an error:

$ convert -version
Version: ImageMagick 6.5.7-8 2012-08-17 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC
Features: OpenMP
$ convert packetloss.png x.bmp
convert: Invalid colormap index `packetloss.png' @ image.c/SyncImage/3849.

R=r
CC=golang-dev
https://golang.org/cl/6822065
2012-11-01 11:46:06 +11:00
Adam Langley
5176481f16 crypto/cipher: add examples
Fixes #1390.

R=golang-dev, minux.ma, adg, agl
CC=golang-dev
https://golang.org/cl/6631044
2012-10-31 16:37:26 -04:00
Rob Pike
a90b3a5528 strconv: update to unicode 6.2.0
Fixes build, too.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6775088
2012-10-31 10:11:04 -07:00
Marcel van Lohuizen
e14cf90a8b unicode: move unicode and related packages to Unicode 6.2.0.
R=r, mpvl
CC=golang-dev
https://golang.org/cl/6818067
2012-10-31 17:32:16 +01:00
Marcel van Lohuizen
b8b329451c exp/locale/collate: implementation of tailorings and table generation.
Tailorings are represented by removing and reinserting entries from a linked list.
After all tailorings are done, missing weights are computed and verified.
This implementation assumes that entries that are used in expansions are not
reinserted at a later point.  This considerably simplifies the implementation.

R=r
CC=golang-dev
https://golang.org/cl/6739052
2012-10-31 14:28:44 +01:00
Marcel van Lohuizen
4c1a6f84f8 exp/locale/collate: removed weights struct to allow for faster and easier
incremental comparisons. Instead, processing is now done directly on colElems.
As a result, the size of the weights array is now reduced by 75%.
Details:
- Primary value of type 1 colElem is shifted by 1 bit so that primaries
  of all types can be compared without shifting.
- Quaternary values are now stored in the colElem itself. This is possible
  as quaternary values other than 0 or maxQuaternary are only needed when other
  values are ignored.
- Simplified processWeights by removing cases that are needed for ICU but not
  for us (our CJK primary values fit in a single value).

R=r
CC=golang-dev
https://golang.org/cl/6817054
2012-10-31 14:28:18 +01:00
Marcel van Lohuizen
bc0783dbe5 exp/locale/collate: add context to entry.
R=r
CC=golang-dev
https://golang.org/cl/6727049
2012-10-31 14:02:43 +01:00
Peter Waller
3494010f7d syscall/exec_linux: enable changing controlling tty
As discussed in the following thread:
https://groups.google.com/forum/?fromgroups=#!topic/golang-dev/emeJffxWhVo

This is required to enable applications such as `less` to use something
other than stdin as the controlling terminal.

R=dave, iant
CC=bradfitz, golang-dev
https://golang.org/cl/6785057
2012-10-30 17:36:18 -07:00
Alex Brainman
fa3e4fc429 net: fix connection resets when closed on windows
It is common to close network connection while another goroutine is
blocked reading on another goroutine. This sequence corresponds to
windows calls to WSARecv to start io, followed by GetQueuedCompletionStatus
that blocks until io completes, and, finally, closesocket called from
another thread. We were expecting that closesocket would unblock
GetQueuedCompletionStatus, and it does, but not always
(http://code.google.com/p/go/issues/detail?id=4170#c5). Also that sequence
results in connection is being reset.

This CL inserts CancelIo between GetQueuedCompletionStatus and closesocket,
and waits for both WSARecv and GetQueuedCompletionStatus to complete before
proceeding to closesocket.  This seems to fix both connection resets and
issue 4170. It also makes windows code behave similar to unix version.

Unfortunately, CancelIo needs to be called on the same thread as WSARecv.
So we have to employ strategy we use for connections with deadlines to
every connection now. It means, there are 2 unavoidable thread switches
for every io. Some newer versions of windows have new CancelIoEx api that
doesn't have these drawbacks, and this CL uses this capability when available.
As time goes by, we should have less of CancelIo and more of CancelIoEx
systems. Computers with CancelIoEx are also not affected by issue 4195 anymore.

Fixes #3710
Fixes #3746
Fixes #4170
Partial fix for issue 4195

R=golang-dev, mikioh.mikioh, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6604072
2012-10-31 10:24:37 +11:00
Nigel Tao
ad487dad75 image/jpeg: don't call ensureNBits unless we have to.
benchmark                     old ns/op    new ns/op    delta
BenchmarkDecodeBaseline         3155638      2783998  -11.78%
BenchmarkDecodeProgressive      4008088      3660310   -8.68%

R=r, bradfitz
CC=golang-dev
https://golang.org/cl/6775072
2012-10-31 10:02:11 +11:00
Alexey Borzenkov
d12a7d39d1 net: use read deadline in Accept on windows
Fixes #4296.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/6815044
2012-10-31 09:58:05 +11:00
Rob Pike
8884fabfd7 reflect: improve documentation for DeepEqual regarding maps
Keys use ==; values use deep equality. Also remove the word 'member'.
Fixes #4258.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6812055
2012-10-30 14:42:47 -07:00
Robert Griesemer
465b9c35e5 gofmt: apply gofmt -w src misc
Remove trailing whitespace in comments.
No other changes.

R=r
CC=golang-dev
https://golang.org/cl/6815053
2012-10-30 13:38:01 -07:00
Robert Griesemer
db2b6ed854 go/printer, gofmt: trim trailing whitespace in comments
Also: updated go fix testcases to pass tests.

Fixes #4310.

R=r
CC=golang-dev
https://golang.org/cl/6810055
2012-10-30 13:09:47 -07:00
Dave Cheney
640d818f2a archive/zip: handle corrupt extra data records
Fixes #4302.

R=golang-dev, bradfitz, adg
CC=golang-dev
https://golang.org/cl/6811048
2012-10-31 03:51:59 +11:00
Robert Griesemer
d77eb12998 exp/gotype: add more test packages
R=r
CC=golang-dev
https://golang.org/cl/6822051
2012-10-30 09:42:43 -07:00
Brad Fitzpatrick
1d61c9bb3e io: add ByteWriter interface
API change.

R=golang-dev, dsymonds, nigeltao, rsc, r
CC=golang-dev
https://golang.org/cl/6760045
2012-10-30 10:51:29 +01:00
Nigel Tao
daf43ba476 image/jpeg: change block from [64]int to [64]int32.
On 6g/linux:
benchmark                     old ns/op    new ns/op    delta
BenchmarkFDCT                      4606         4241   -7.92%
BenchmarkIDCT                      4187         3923   -6.31%
BenchmarkDecodeBaseline         3154864      3170224   +0.49%
BenchmarkDecodeProgressive      4072812      4017132   -1.37%
BenchmarkEncode                39406920     34596760  -12.21%

Stack requirements before (from 'go tool 6g -S'):
(scan.go:37) TEXT    (*decoder).processSOS+0(SB),$1352-32
(writer.go:448) TEXT    (*encoder).writeSOS+0(SB),$5344-24

after:
(scan.go:37) TEXT    (*decoder).processSOS+0(SB),$1064-32
(writer.go:448) TEXT    (*encoder).writeSOS+0(SB),$2520-24

Also, in encoder.writeSOS, re-use the yBlock scratch buffer for Cb and
Cr. This reduces the stack requirement slightly, but also avoids an
unlucky coincidence where a BenchmarkEncode stack split lands between
encoder.writeByte and bufio.Writer.WriteByte, which occurs very often
during Huffman encoding and is otherwise disasterous for the final
benchmark number. FWIW, the yBlock re-use *without* the s/int/int32/
change does not have a noticable effect on the benchmarks.

R=r
CC=golang-dev, rsc
https://golang.org/cl/6823043
2012-10-30 11:10:08 +11:00
Roger Peppe
9c775353b9 encoding/json: tweak docs
"JSON object" means something specific, which
isn't the case here.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6789044
2012-10-29 20:58:24 +01:00
Dmitriy Vyukov
c242aa34cc syscalls: annotate Sendfile() for race detector
Fixes #4306.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6816054
2012-10-29 23:15:06 +04:00
Pawel Szczur
4918e3a960 net/http/client.go: fix cookie handling on (*Client) Do()
Fix the problem with no cookie handling when sending
other than GET or HEAD request through
(*Client) Do(*Request) (*Resposne, error).
https://code.google.com/p/go/issues/detail?id=3985

Adds a function (*Client) send(*Request) (*Reponse, error):
- sets cookies from CookieJar to request,
- sends request
- parses a reply cookies and updates CookieJar

Fixes #3985

R=bradfitz
CC=gobot, golang-dev
https://golang.org/cl/6653049
2012-10-29 17:56:31 +01:00
Adam Langley
184e7a2bf2 crypto/x509: always write validity times in UTC.
RFC 5280 section 4.1.2.5.1 says so.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6775068
2012-10-29 11:16:58 -04:00
Adam Langley
4d17fe3cd6 encoding/asn1: don't convert UTCTime to UTC.
Previously we converted a time to UTC *and* serialized the timezone of
the original time. With this change, we serialize a UTCTime in the
original timezone.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6817048
2012-10-29 11:16:05 -04:00
Taj Khattra
1158c6b9c6 container/list: fix typo
R=golang-dev, fullung, dave, minux.ma
CC=golang-dev
https://golang.org/cl/6682046
2012-10-28 21:16:50 +11:00
Patrick Smith
3c808164ad sort: Fixed a typo in the documentation for SearchStrings.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6777066
2012-10-28 10:07:59 +11:00
Ian Lance Taylor
5611e8b59f syscall: fix creds_test to reliably close os.File
Before this patch the test would close the file descriptor but
not the os.File.  When the os.File was GC'ed, the finalizer
would close the file descriptor again.  That would cause
problems if the same file descriptor were returned by a later
call to open in another test.

On my system:

> GOGC=30 go test
--- FAIL: TestPassFD (0.04 seconds)
passfd_test.go:62: 	FileConn: dup: bad file descriptor
FAIL

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6776053
2012-10-26 10:31:03 -07:00
Shenghou Ma
f9902c7197 encoding/binary: ReadVarint reads a signed number, not unsigned number
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6762051
2012-10-26 21:14:34 +08:00
Dave Cheney
067315c647 net: avoid allocation in setAddr
setAddr was showing up in profiles due to string concatenation construction the os.File name field. netFD.sysfile's Name() is never used, except in dup() so I believe it is safe to avoid this allocation.

R=mikioh.mikioh, rsc
CC=golang-dev
https://golang.org/cl/6742058
2012-10-26 19:41:21 +11:00
Rémy Oudompheng
38070a72c5 reflect: stop thinking that MaxFloat32 overflows float32.
Fixes #4282.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6759052
2012-10-26 08:39:36 +02:00
Dmitriy Vyukov
320df44f04 runtime: switch to 64-bit goroutine ids
Fixes #4275.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6759053
2012-10-26 10:13:06 +04:00
Marcel van Lohuizen
b575e3ca99 exp/locale/collate: slightly changed collation elements:
- Allow secondary values below the default value in second form. This is
  to support before tags for secondary values, as used by Chinese.
- Eliminate collation elements that are guaranteed to be immaterial
  after a weight increment.

R=r
CC=golang-dev
https://golang.org/cl/6739051
2012-10-25 13:02:31 +02:00
Shenghou Ma
7c412e962c syscall: implement (*PtraceRegs).PC() and SetPC()
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6763043
2012-10-25 13:41:04 +08:00
Marcel van Lohuizen
6653d76ef6 exp/locale/collate/build: fixed problem where blocks for first byte need
different indexes for values and index blocks. Fixes many regressions.

R=r
CC=golang-dev
https://golang.org/cl/6737057
2012-10-24 11:41:05 +02:00
Marcel van Lohuizen
34f2050626 exp/locale/collate: clarification in comments on use of returned value.
R=r
CC=golang-dev
https://golang.org/cl/6752043
2012-10-24 11:40:32 +02:00
Marcel van Lohuizen
a35f23f34e exp/locale/collate/tools/colcmp: add locale to output of regression failure.
R=r
CC=golang-dev
https://golang.org/cl/6749058
2012-10-24 11:28:18 +02:00
Shenghou Ma
7c44edf425 runtime, runtime/race: add missing if(raceenabled), update package docs of pkg race
R=dvyukov
CC=golang-dev
https://golang.org/cl/6733058
2012-10-23 02:33:51 +08:00
Robert Griesemer
7c03cd32b6 exp/type/staging: implemented recent spec changes
Also:
- type-checking receivers
- get rid of some multiple errors at the same position

R=rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6709061
2012-10-22 11:28:21 -07:00
Nigel Tao
eb7d56965b os: fix documentation typos: s/an array/a slice/.
R=dsymonds
CC=golang-dev
https://golang.org/cl/6736057
2012-10-22 16:26:47 +11:00
Patrick Smith
2e67dd861d encoding/xml: expand allowed entity names
Previously, multi-byte characters were not allowed. Also certain single-byte
characters, such as '-', were disallowed.
Fixes #3813.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6641052
2012-10-21 20:33:24 -04:00
Jingcheng Zhang
5d05c7800e runtime: sizeclass in MSpan should be int32.
R=golang-dev, minux.ma, dave, rsc
CC=golang-dev
https://golang.org/cl/6643046
2012-10-21 20:32:43 -04:00
Nigel Tao
80c4eac637 go/build: document the behavior of multiple build constraints.
R=rsc, pkleiweg
CC=golang-dev
https://golang.org/cl/6725052
2012-10-22 11:15:17 +11:00
Jan Ziak
4a191c2c1b runtime: store types of allocated objects
R=rsc
CC=golang-dev
https://golang.org/cl/6569057
2012-10-21 17:41:32 -04:00
Mikio Hara
4545dc6a69 net: add test for Conn, PacketConn and Listener
I just realized that there is no good place for adding
exposed function or method tests because server, unicast
and multicast_test.go do test complicated multiple test
objects, platform behaviros, protocol behaviors and API,
at the same time. Perhaps splitting them into per test
object might be better, so this CL provides tests focused
on API.

R=rsc
CC=gobot, golang-dev
https://golang.org/cl/6501057
2012-10-21 17:17:51 -04:00
Evan Shaw
772decbc80 reflect: make Index and Slice accept strings
Fixes #3284.

R=golang-dev, r, rsc
CC=golang-dev
https://golang.org/cl/6643043
2012-10-21 17:02:10 -04:00
Shenghou Ma
c1b7ddc6aa runtime: update docs for MemStats.PauseNs
PauseNs is a circular buffer of recent pause times, and the
most recent one is at [((NumGC-1)+256)%256].

   Also fix comments cross-linking the Go and C definition of
various structs.

R=golang-dev, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/6657047
2012-10-22 01:08:13 +08:00
Shenghou Ma
3e3fa7b5f1 runtime: ~3.7x speed up of div/mod on ARM
benchmark                      old ns/op    new ns/op    delta
BenchmarkUint32Div7                  281           75  -73.06%
BenchmarkUint32Div37                 281           75  -73.02%
BenchmarkUint32Div123                281           75  -73.02%
BenchmarkUint32Div763                280           75  -72.89%
BenchmarkUint32Div1247               280           75  -72.93%
BenchmarkUint32Div9305               281           75  -73.02%
BenchmarkUint32Div13307              281           75  -73.06%
BenchmarkUint32Div52513              281           75  -72.99%
BenchmarkUint32Div60978747           281           63  -77.33%
BenchmarkUint32Div106956295          280           63  -77.21%
BenchmarkUint32Mod7                  280           77  -72.21%
BenchmarkUint32Mod37                 280           77  -72.18%
BenchmarkUint32Mod123                280           77  -72.25%
BenchmarkUint32Mod763                280           77  -72.18%
BenchmarkUint32Mod1247               280           77  -72.21%
BenchmarkUint32Mod9305               280           77  -72.21%
BenchmarkUint32Mod13307              280           77  -72.25%
BenchmarkUint32Mod52513              280           77  -72.18%
BenchmarkUint32Mod60978747           280           63  -77.25%
BenchmarkUint32Mod106956295          280           63  -77.21%

R=dave, rsc
CC=dave, golang-dev, rsc
https://golang.org/cl/6717043
2012-10-20 16:40:19 +08:00
Nigel Tao
0ba5ec53b0 bufio: remove a little unnecessary indirection in tests.
R=mchaten, r
CC=golang-dev
https://golang.org/cl/6739045
2012-10-20 13:02:29 +11:00
Oling Cat
c117da37a2 unsafe: fix a typo
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6736048
2012-10-19 16:35:15 +11:00
Nigel Tao
e55fdff210 bufio: make Writer.ReadFrom not flush prematurely. For example,
many small writes to a network may be less efficient that a few
large writes.

This fixes net/http's TestClientWrites, broken by 6565056 that
introduced Writer.ReadFrom. That test implicitly assumed that
calling io.Copy on a *bufio.Writer wouldn't write to the
underlying network until the buffer was full.

R=dsymonds
CC=bradfitz, golang-dev, mchaten, mikioh.mikioh
https://golang.org/cl/6743044
2012-10-19 16:32:00 +11:00
Michael Chaten
2a4818dd11 bufio: Implement io.ReaderFrom for (*Writer).
This is part 2 of 2 for issue 4028.

benchmark                        old ns/op    new ns/op    delta
BenchmarkWriterCopyOptimal           53293        28326  -46.85%
BenchmarkWriterCopyUnoptimal         53757        30537  -43.19%
BenchmarkWriterCopyNoReadFrom        53192        36642  -31.11%

Fixes #4028.

R=nigeltao
CC=golang-dev
https://golang.org/cl/6565056
2012-10-19 11:22:51 +11:00
Nigel Tao
90ad6a2d11 runtime: update comment for the "extern register" variables g and m.
R=rsc, minux.ma, ality
CC=dave, golang-dev
https://golang.org/cl/6620050
2012-10-19 11:02:32 +11:00
Nigel Tao
5abf4bdc27 image/draw: fast-path for 4:4:0 chroma subsampled sources.
R=r
CC=golang-dev
https://golang.org/cl/6699049
2012-10-19 10:55:41 +11:00
Ian Lance Taylor
1e6d9f49da encoding/xml: correctly escape newline, carriage return, and tab
The generated encodings are those from
http://www.w3.org/TR/2000/WD-xml-c14n-20000119.html#charescaping

The change to the decoder ensures that we turn &#xD; in the
input into \r, not \n.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6747043
2012-10-18 13:40:45 -07:00
Rémy Oudompheng
2abaaefa72 image/jpeg: make TestDCT faster.
The value of cosines are cached in a global array
instead of being recomputed each time.
The test was terribly slow on arm.

R=golang-dev, dave, nigeltao
CC=golang-dev
https://golang.org/cl/6733046
2012-10-18 21:28:04 +02:00
Stephen McQuay
a5b0c67d5f net: add LookupNS(domain string)
Fixes #4224.

R=golang-dev, dave, minux.ma, mikioh.mikioh, alex.brainman, rsc, herbert.fischer
CC=golang-dev
https://golang.org/cl/6675043
2012-10-18 15:39:04 +09:00
Nigel Tao
9dc3152668 exp/html: update package docs and add an example; a node's children is
a linked list, not a slice.

R=r, minux.ma
CC=golang-dev
https://golang.org/cl/6618055
2012-10-18 10:25:50 +11:00
Rémy Oudompheng
a4682348c2 cmd/gc: don't squash complex literals when inlining.
Since this patch changes the way complex literals are written
in export data, there are a few other glitches.

Fixes #4159.

R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/6674047
2012-10-17 20:33:44 +02:00
Shane Hansen
fcd5fd2ad4 crypto/cipher: panic on invalid IV length
Give better user feedback when invalid IV is used
to construct a cipher.

Fixes #3411

R=golang-dev, agl
CC=golang-dev
https://golang.org/cl/6652053
2012-10-17 14:29:00 -04:00
Adam Langley
73f11171b4 math/big: add 4-bit, fixed window exponentiation.
A 4-bit window is convenient because 4 divides both 32 and 64,
therefore we never have a window spanning words of the exponent.
Additionaly, the benefit of a 5-bit window is only 2.6% at 1024-bits
and 3.3% at 2048-bits.

This code is still not constant time, however.

benchmark                        old ns/op    new ns/op    delta
BenchmarkRSA2048Decrypt           17108590     11180370  -34.65%
Benchmark3PrimeRSA2048Decrypt     13003720      7680390  -40.94%

R=gri
CC=golang-dev
https://golang.org/cl/6716048
2012-10-17 11:19:26 -04:00
Shenghou Ma
ace9ff4578 sync/atomic: FreeBSD/ARM support
only supports ARMv6K and newer ARM cores.

R=rsc, dave
CC=golang-dev
https://golang.org/cl/6601064
2012-10-17 14:27:58 +08:00
Rob Pike
ec1ef16cea path/filepath: better documentation for WalkFunc
Define the properties of the arguments better. In particular,
explain that the path is (sort of) relative to the argument to
Walk.

Fixes #4119.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6721048
2012-10-17 16:00:09 +11:00
Dave Cheney
8c2b131cd1 net: return error from pollster rather than panicing
Fixes #3590.

R=bradfitz, mikioh.mikioh, iant, bsiegert
CC=golang-dev
https://golang.org/cl/6684054
2012-10-17 09:41:00 +11:00
Robert Griesemer
7565726875 math/big: fix big.Exp and document better
- always return 1 for y <= 0
- document that the sign of m is ignored
- protect against div-0 panics by treating
  m == 0 the same way as m == nil
- added extra tests

Fixes #4239.

R=agl, remyoudompheng, agl
CC=golang-dev
https://golang.org/cl/6724046
2012-10-16 13:46:27 -07:00
Adam Langley
cfa1ba34cc crypto/tls: make closeNotify a warning alert.
The RFC doesn't actually have an opinion on whether this is a fatal or
warning level alert, but common practice suggests that it should be a
warning.

This involves rebasing most of the tests.

Fixes #3413.

R=golang-dev, shanemhansen, rsc
CC=golang-dev
https://golang.org/cl/6654050
2012-10-16 15:40:37 -04:00
Robert Griesemer
71588bc2bc exp/types/staging: index and slice type checks
Also: handle assignments to the blank identifier.

R=rsc
CC=golang-dev
https://golang.org/cl/6658050
2012-10-16 10:20:03 -07:00
Dmitriy Vyukov
f24323c93e runtime: fix spurious deadlock crashes
Fixes #4243.

R=golang-dev, iant
CC=golang-dev, sebastien.paolacci
https://golang.org/cl/6682050
2012-10-16 14:41:32 +04:00
Dmitriy Vyukov
6273c7324f runtime: add missing if(raceenabled)
R=0xe2.0x9a.0x9b, minux.ma, iant, dave
CC=golang-dev
https://golang.org/cl/6654052
2012-10-15 13:54:31 +04:00
Nigel Tao
1f31598e86 image/jpeg: re-organize the processSOS code.
This is a straight copy/paste, and the deletion of a TODO. There are
no other changes.

R=r
CC=golang-dev
https://golang.org/cl/6687049
2012-10-15 13:28:30 +11:00
Nigel Tao
8b624f607f image/jpeg: decode progressive JPEGs.
To be clear, this supports decoding the bytes on the wire into an
in-memory image. There is no API change: jpeg.Decode will still not
return until the entire image is decoded.

The code is obviously more complicated, and costs around 10% in
performance on baseline JPEGs. The processSOS code could be cleaned up a
bit, and maybe some of that loss can be reclaimed, but I'll leave that
for follow-up CLs, to keep the diff for this one as small as possible.

Before:
BenchmarkDecode	    1000	   2855637 ns/op	  21.64 MB/s
After:
BenchmarkDecodeBaseline	     500	   3178960 ns/op	  19.44 MB/s
BenchmarkDecodeProgressive	     500	   4082640 ns/op	  15.14 MB/s

Fixes #3976.

The test data was generated by:
# Create intermediate files; cjpeg on Ubuntu 10.04 can't read PNG.
convert video-001.png video-001.bmp
convert video-005.gray.png video-005.gray.pgm
# Create new test files.
cjpeg -quality 100 -sample 1x1,1x1,1x1 -progressive video-001.bmp > video-001.progressive.jpeg
cjpeg -quality 50 -sample 2x2,1x1,1x1 video-001.bmp > video-001.q50.420.jpeg
cjpeg -quality 50 -sample 2x1,1x1,1x1 video-001.bmp > video-001.q50.422.jpeg
cjpeg -quality 50 -sample 1x1,1x1,1x1 video-001.bmp > video-001.q50.444.jpeg
cjpeg -quality 50 -sample 2x2,1x1,1x1 -progressive video-001.bmp > video-001.q50.420.progressive.jpeg
cjpeg -quality 50 -sample 2x1,1x1,1x1 -progressive video-001.bmp > video-001.q50.422.progressive.jpeg
cjpeg -quality 50 -sample 1x1,1x1,1x1 -progressive video-001.bmp > video-001.q50.444.progressive.jpeg
cjpeg -quality 50 video-005.gray.pgm > video-005.gray.q50.jpeg
cjpeg -quality 50 -progressive video-005.gray.pgm > video-005.gray.q50.progressive.jpeg
# Delete intermediate files.
rm video-001.bmp video-005.gray.pgm

R=r
CC=golang-dev
https://golang.org/cl/6684046
2012-10-15 11:21:20 +11:00
David Symonds
f2045aadd9 time: accept numbers larger than 2^32 in ParseDuration.
Fixes #3374.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6683047
2012-10-15 07:50:13 +11:00
Shenghou Ma
240834374a io/ioutil: use pathname instead of name in docs to avoid confusion
caller of ioutil.TempFile() can use f.Name() to get "pathname"
of the temporary file, instead of just the "name" of the file.

Also remove an out-of-date comment about random number state.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6649054
2012-10-13 19:05:22 +08:00
Anthony Martin
422da762b7 compress/bzip2: use io.ByteReader instead of internal interface
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6663044
2012-10-12 14:09:24 -07:00
Shenghou Ma
366268aa79 runtime: FreeBSD/ARM support
R=rsc
CC=golang-dev
https://golang.org/cl/6625071
2012-10-12 23:19:39 +08:00
Shenghou Ma
378d7ef59f syscall: FreeBSD/ARM support
R=rsc, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6657048
2012-10-12 16:26:42 +08:00
Rob Pike
e171b97ee6 fmt: document some undocumented details
Better explanation of width for floating-point values.
Explain that scanning does not handle %#q etc.

Fixes #4202.
Fixes #4206.

R=golang-dev, adg, rsc, iant
CC=golang-dev
https://golang.org/cl/6620074
2012-10-12 16:16:55 +11:00
Evan Shaw
eae25d430d bytes, strings: add (*Reader).WriteTo
Fixes #4031.

R=golang-dev, bradfitz, remyoudompheng, r, dave
CC=golang-dev
https://golang.org/cl/6632046
2012-10-12 14:43:50 +11:00