Rob Pike [Sat, 9 Mar 2013 00:39:54 +0000 (16:39 -0800)]
text/template: revert minor change to Name method
For better printing, I recently changed Name to return "<unnamed>" for templates
with empty names, but this causes trouble for the many packages that used "" as
the template name, so restore the old behavior.
It's usually printed as a quoted string anyway, so it should be fine.
Russ Cox [Fri, 8 Mar 2013 05:23:59 +0000 (21:23 -0800)]
cmd/6l, cmd/8l: fix BSD builds
Before this CL, running
cd misc/cgo/test
go test -c
readelf --dyn-syms test.test | grep cgoexp
turned up many UNDEF symbols corresponding to symbols actually
in the binary but marked only cgo_export_static. Only symbols
marked cgo_export_dynamic should be listed in this mode.
And if the symbol is going to be listed, it should be listed with its
actual address instead of UNDEF.
The Linux dynamic linker didn't care about the seemingly missing
symbols, but the BSD one did.
This CL eliminates the symbols from the dyn-syms table.
Russ Cox [Fri, 8 Mar 2013 03:57:10 +0000 (19:57 -0800)]
runtime: change 386 startup convention
Now the default startup is that the program begins at _rt0_386_$GOOS,
which behaves as if calling main(argc, argv). Main jumps to _rt0_386.
This makes the _rt0_386 entry match the expected semantics for
the standard C "main" function, which we can now provide for use when
linking against a standard C library.
Brad Fitzpatrick [Fri, 8 Mar 2013 01:56:00 +0000 (17:56 -0800)]
net/http: Transport socket late binding
Implement what Chrome calls socket "late binding". See:
https://insouciant.org/tech/connection-management-in-chromium/
In a nutshell, if our HTTP client needs a TCP connection to a
remote host and there's not an idle one available, rather than
kick off a dial and wait for that specific dial, we instead
kick off a dial and wait for either our own dial to finish, or
any other TCP connection to that same host to become
available.
The implementation looks like a classic "Learning Go
Concurrency" slide.
Chrome's commit and numbers:
http://src.chromium.org/viewvc/chrome?view=rev&revision=36230
Akshat Kumar [Thu, 7 Mar 2013 23:54:44 +0000 (00:54 +0100)]
syscall: Plan 9: use lightweight errstr in entersyscall mode
Change 231af8ac63aa (CL 7314062) made runtime.enteryscall()
set m->mcache = nil, which means that we can no longer use
syscall.errstr in syscall.Syscall and syscall.Syscall6, since it
requires a new buffer to be allocated for holding the error string.
Instead, we use pre-allocated per-M storage to hold error strings
from syscalls made while in entersyscall mode, and call
runtime.findnull to calculate the lengths.
Fixes #4994.
R=rsc, rminnich, ality, dvyukov, rminnich, r
CC=golang-dev
https://golang.org/cl/7567043
Mikio Hara [Thu, 7 Mar 2013 21:51:06 +0000 (06:51 +0900)]
net: fix multicast listener tests
This CL splits multicast listener tests into two; for IPv4 and
for IPv6. It also removes redundant test inputs and makes sure
that assignment of multicast interface to stablize the tests.
Dominik Honnef [Thu, 7 Mar 2013 18:12:37 +0000 (13:12 -0500)]
misc/emacs: Rewrite gofmt to use own function for applying patch instead of using diff-mode.
Instead of relying on gofmt's diff output (which is a unified
diff), we manually invoke diff -n and produce an RCS format diff,
which can easily be parsed in Emacs, with the go--apply-rcs-patch
function.
This fixes undocumented issues with the old implementation such as
skipping over hunks of changes, and it fixes the documented issue
of not being able to handle file names that include whitespace.
It can also apply the patch on a buffer that has no file name
attached at all.
Last but not least, it greatly simplifies the gofmt function
itself.
Dmitriy Vyukov [Thu, 7 Mar 2013 17:44:24 +0000 (21:44 +0400)]
net: more refactoring in preparation for runtime integrated pollster
Move pollServer from fd_unix.go to fd_poll_unix.go.
Add pollServerInit(*NetFD) to allow custom initialization.
Add pollServer.Close(*NetFD) to allow custom finalization.
Move setDeadline() to fd_poll_unix.go to allow custom handling of deadlines.
Move newPollServer() to fd_poll_unix.go to allow custom initialization.
No logical code changes.
The next step will be to turn off fd_poll_unix.go for some platform
(I have changes for darwin/linux) and redirect it into runtime. See:
https://golang.org/cl/7569043/diff/2001/src/pkg/net/fd_poll_runtime.go
Dmitriy Vyukov [Thu, 7 Mar 2013 17:39:59 +0000 (21:39 +0400)]
runtime: fix deadlock
The deadlock episodically occurs on misc/cgo/test/TestCthread.
The problem is that starttheworld() leaves some P's with local work
without M's. Then all active M's enter into syscalls, but reject to
wake another M's due to the following check (both in entersyscallblock() and in retake()):
if(p->runqhead == p->runqtail &&
runtime·atomicload(&runtime·sched.nmspinning) +
runtime·atomicload(&runtime·sched.npidle) > 0)
continue;
Dmitriy Vyukov [Thu, 7 Mar 2013 13:03:40 +0000 (17:03 +0400)]
net: fix accept/connect deadline handling
Ensure that accept/connect respect deadline,
even if the operation can be executed w/o blocking.
Note this changes external behavior, but it makes
it consistent with read/write.
Factor out deadline check into pollServer.PrepareRead/Write,
in preparation for edge triggered pollServer.
Ensure that pollServer.WaitRead/Write are not called concurrently
by adding rio/wio locks around connect/accept.
Rob Pike [Wed, 6 Mar 2013 23:47:49 +0000 (15:47 -0800)]
doc/effective_go.html: unify and expand the discussion of Sprintf and String
It's a common mistake to build a recursive String method; explain it well and
show how to avoid it.
Rob Pike [Wed, 6 Mar 2013 20:49:56 +0000 (12:49 -0800)]
cmd/vet: isolate the type checking code into a separate file
We can enable/disable type checking with a build tag.
Should simplify cutting the go1.1 distribution free of go/types.
Russ Cox [Wed, 6 Mar 2013 20:03:04 +0000 (15:03 -0500)]
runtime: change amd64 startup convention
Now the default startup is that the program begins at _rt0_amd64_$GOOS,
which sets DI = argc, SI = argv and jumps to _rt0_amd64.
This makes the _rt0_amd64 entry match the expected semantics for
the standard C "main" function, which we can now provide for use when
linking against a standard C library.
Dominik Honnef [Wed, 6 Mar 2013 19:35:29 +0000 (14:35 -0500)]
misc/emacs: Add compatibility for GNU Emacs 23 and XEmacs >=21.5.32
This CL adds compatibility for GNU Emacs 23 (fixing fontification
issues) and XEmacs >=21.5.32 (fixing a lot of issues). Earlier
versions of XEmacs will not be supported because they do not
support POSIX character classes. Because of that, we also make use
of a lot of functions that were added in 21.5.32.
A known and currently unfixable issue with XEmacs is that go-mode
will not always fontify identifiers that use unicode correctly.
All changes for XEmacs are annotated in the diff.
Note: go--position-bytes is not currently used anywhere, but will
be in a future CL.
Brad Fitzpatrick [Wed, 6 Mar 2013 02:47:27 +0000 (18:47 -0800)]
net/http: close TCP connection on Response.Body.Close
Previously the HTTP client's (*Response).Body.Close would try
to keep reading until EOF, hoping to reuse the keep-alive HTTP
connection, but the EOF might never come, or it might take a
long time. Now we immediately close the TCP connection if we
haven't seen EOF.
This shifts the burden onto clients to read their whole response
bodies if they want the advantage of reusing TCP connections.
In the future maybe we could decide on heuristics to read some
number of bytes for some max amount of time before forcefully
closing, but I'd rather not for now.
Statistically, touching this code makes things regress, so I
wouldn't be surprised if this introduces new bugs, but all the
tests pass, and I think the code is simpler now too. Maybe.
Rob Pike [Tue, 5 Mar 2013 22:13:53 +0000 (14:13 -0800)]
doc/effective_go.html: update slices and maps.
Drop the phrase "reference types", which has caused confusion.
Add a section about 2D arrays, a common newbie question.
traceback_arm fails with a missing pc. It needs CL 7494043.
But that only makes the build break later, this time with
"invalid freelist". Roll back until it can be fixed correctly.
««« original CL description
runtime: restrict stack root scan to locals and arguments
Joel Sing [Tue, 5 Mar 2013 10:40:37 +0000 (21:40 +1100)]
syscall: handle getsockname for unix sockets on openbsd 5.2
On OpenBSD 5.2, calling getsockname on an unbound Unix domain socket
results in a successful syscall, however the AF is unset and the length
is returned as zero. This has been changed to more portable behaviour,
which will be included in the OpenBSD 5.3 release.
For now, work around this by treating a successful getsockname() call
that returns a family of AF_UNSPEC and length of zero as a AF_UNIX
socket.
Dmitriy Vyukov [Tue, 5 Mar 2013 07:40:17 +0000 (09:40 +0200)]
runtime: fix false positive deadlock when using runtime.Goexit
Fixes #4893.
Actually it's fixed by cl/7314062 (improved scheduler),
just submitting the test.
Dmitriy Vyukov [Tue, 5 Mar 2013 07:38:15 +0000 (09:38 +0200)]
runtime: declare addtimer/deltimer in runtime.h
In preparation for integrated network poller
(https://golang.org/cl/7326051),
this is required to handle deadlines.
Robert Griesemer [Mon, 4 Mar 2013 21:55:35 +0000 (13:55 -0800)]
spec: terminating statements for functions
The only functional change is the new section
on terminating statements.
There is a minor syntax rewrite (not change)
of function declarations to make it easier to
refer to the notion of a function from all places
where it is used (function decls, method decls,
and function literals).
Includes some minor fixes/additions of missing links.
Russ Cox [Mon, 4 Mar 2013 16:23:17 +0000 (11:23 -0500)]
cmd/cgo: use explicit flag to emit dynamic linker path
Using -import_runtime_cgo would have worked great except
that it doesn't get passed to the second invocation of cgo,
and that's the one that writes the relevant file.
Fixes ARM build on systems with a different dynamic linker
than the one 5l assumes (like Gentoo).
Volker Dobler [Mon, 4 Mar 2013 03:54:36 +0000 (14:54 +1100)]
image/png: always set up palette during DecodeConfig
The old code would decode the palette only for 8-bit
images during a DecodeConfig.
This CL keeps the behavior for 8-bit images and sets
up the decoded palette also for 1, 2 and 4-bit images.
Andrew Gerrand [Sun, 3 Mar 2013 22:02:45 +0000 (09:02 +1100)]
cmd/godoc: move note argument to godoc.go
Fixes the App Engine version of godoc. The other fix is to duplicate
this code inside appinit.go. I think initHandlers is the right place
to put the strings.Split call, as the notesToShow var is used by
docServer, which is what initHandlers sets up.
Shenghou Ma [Sat, 2 Mar 2013 22:50:17 +0000 (06:50 +0800)]
cmd/dist: support for NetBSD/ARM
1. when executing a unsupported VFP instruction, the NetBSD kernel somehow
doesn't report SIGILL, and instead just spin and spin, we add a alarm(2)
to detect this case (albeit this is a kernel bug).
2. NetBSD/ARM's VFP11 support is not complete, so temporarily disable it.
3. The default gcc shipped with NetBSD-current mis-optimizes our code
at -O2, so lower the optimization level to -O1 on NetBSD/ARM.
Dmitriy Vyukov [Sat, 2 Mar 2013 06:36:06 +0000 (08:36 +0200)]
runtime: move TestGcSys into a separate process
Fixes #4904.
The problem was that when the test runs the heap had grown to ~100MB,
so GC allows it to grow to 200MB, and so the test fails.
Moving the test to a separate process makes it much more isolated and stable.