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
Dave Cheney [Wed, 28 Nov 2012 00:29:25 +0000 (11:29 +1100)]
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.
Robert Griesemer [Tue, 27 Nov 2012 18:29:49 +0000 (10:29 -0800)]
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.
Jan Ziak [Tue, 27 Nov 2012 18:04:59 +0000 (13:04 -0500)]
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().
Rick Arnold [Tue, 27 Nov 2012 17:58:27 +0000 (12:58 -0500)]
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.
John Graham-Cumming [Tue, 27 Nov 2012 15:21:43 +0000 (10:21 -0500)]
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.
Dmitriy Vyukov [Tue, 27 Nov 2012 08:18:54 +0000 (12:18 +0400)]
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
Brad Fitzpatrick [Mon, 26 Nov 2012 21:31:02 +0000 (13:31 -0800)]
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)
Daniel Morsing [Mon, 26 Nov 2012 21:23:13 +0000 (22:23 +0100)]
cmd/gc: Make sure bools lose idealness when used with logical operators.
Bools from comparisons can be assigned to all bool types, but this idealness would propagate through logical operators when the result should have been lowered to a non-ideal form.
Robert Griesemer [Mon, 26 Nov 2012 21:14:04 +0000 (13:14 -0800)]
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émy Oudompheng [Mon, 26 Nov 2012 20:51:48 +0000 (21:51 +0100)]
cmd/6l, cmd/8l: emit no-ops to separate zero-stack funcs from nosplits.
The stack overflow checker in the linker uses the spadj field
to determine whether stack space will be large enough or not.
When spadj=0, the checker treats the function as a nosplit
and emits an error although the program is correct.
Robert Griesemer [Mon, 26 Nov 2012 20:49:04 +0000 (12:49 -0800)]
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
Mikio Hara [Mon, 26 Nov 2012 15:45:42 +0000 (00:45 +0900)]
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
Dave Cheney [Sun, 25 Nov 2012 23:59:43 +0000 (10:59 +1100)]
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.
Dmitriy Vyukov [Sun, 25 Nov 2012 09:27:32 +0000 (13:27 +0400)]
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
Dave Cheney [Sun, 25 Nov 2012 00:29:06 +0000 (11:29 +1100)]
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.
John Graham-Cumming [Sat, 24 Nov 2012 04:55:19 +0000 (15:55 +1100)]
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.
Robert Griesemer [Wed, 21 Nov 2012 22:40:50 +0000 (14:40 -0800)]
spec: be clearer about the scope of a package name
We have the notion of a PackageName, not package identifier.
As is, it could construed that imports that rename a package
don't have an "imported package identifier" but a local one.
Joel Sing [Wed, 21 Nov 2012 14:25:53 +0000 (01:25 +1100)]
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).
Brad Fitzpatrick [Tue, 20 Nov 2012 03:50:42 +0000 (19:50 -0800)]
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?)
Robert Griesemer [Mon, 19 Nov 2012 21:23:32 +0000 (13:23 -0800)]
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.
Dave Cheney [Sun, 18 Nov 2012 04:31:26 +0000 (15:31 +1100)]
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.
Dave Cheney [Sat, 17 Nov 2012 21:58:54 +0000 (08:58 +1100)]
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.
Shenghou Ma [Sat, 17 Nov 2012 18:23:34 +0000 (02:23 +0800)]
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%