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

8474 Commits

Author SHA1 Message Date
Rob Pike
727b2b6f7d time: handle GMT possibly with offset
Update #3790
Handle time zones like GMT-8.
The more general time zone-matching problem is not yet resolved.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12922043
2013-08-15 10:10:49 +10:00
Russ Cox
904e113615 encoding/xml: support generic encoding interfaces
Remove custom support for time.Time.
No new tests: the tests for the time.Time special case
now test the general case.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12751045
2013-08-14 18:52:09 -04:00
Carl Shapiro
3ec0427a07 cmd/go, runtime/cgo: explicitly target ARMv5T
The baseline architecture had been left to the GCC configured
default which can be more accomodating than the rest of the Go
toolchain.  This prevented instructions used by the 5g compiler,
like BLX, from being used in GCC compiled assembler code.

R=golang-dev, dave, rsc, elias.naur, cshapiro
CC=golang-dev
https://golang.org/cl/12954043
2013-08-14 15:21:53 -07:00
Mikio Hara
88411547d4 net: simplify dial
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12884044
2013-08-15 05:53:53 +09:00
Dmitriy Vyukov
3bd0b0a80d runtime: fix SetBlockProfileRate
It doughtily misses all possible corner cases.
In particular on machines with <1GHz processors,
SetBlockProfileRate(1) disables profiling.
Fixes #6114.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/12936043
2013-08-15 00:20:36 +04:00
Mikio Hara
2eb7c6ec8a net: simplify non-cgo DNS exchange
Also does less buffer allocation in case of TCP fallback.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12925043
2013-08-15 05:08:08 +09:00
Mikio Hara
3a93626b49 net: fix TestTCPLookup
R=golang-dev, dvyukov, dave
CC=golang-dev
https://golang.org/cl/12766044
2013-08-15 05:07:35 +09:00
Russ Cox
54bdfc007f encoding/xml: add, support Marshaler interface
See golang.org/s/go12xml for design.

Repeat of CL 12603044, which was submitted accidentally
and then rolled back.

Fixes #2771.
Fixes #4169.
Fixes #5975.
Fixes #6125.

R=golang-dev
CC=golang-dev
https://golang.org/cl/12919043
2013-08-14 14:58:28 -04:00
Russ Cox
84b0842a59 encoding/xml: add, support Unmarshaler interface
See golang.org/s/go12xml for design.

R=golang-dev, dominik.honnef, dan.kortschak
CC=golang-dev
https://golang.org/cl/12556043
2013-08-14 14:57:45 -04:00
Russ Cox
7e886740d1 encoding/json: support encoding.TextMarshaler, encoding.TextUnmarshaler
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12703043
2013-08-14 14:56:07 -04:00
Russ Cox
5822e7848a runtime: make SetFinalizer(x, f) accept any f for which f(x) is valid
Originally the requirement was f(x) where f's argument is
exactly x's type.

CL 11858043 relaxed the requirement in a non-standard
way: f's argument must be exactly x's type or interface{}.

If we're going to relax the requirement, it should be done
in a way consistent with the rest of Go. This CL allows f's
argument to have any type for which x is assignable;
that's the same requirement the compiler would impose
if compiling f(x) directly.

Fixes #5368.

R=dvyukov, bradfitz, pieter
CC=golang-dev
https://golang.org/cl/12895043
2013-08-14 14:54:31 -04:00
Russ Cox
2560f8fe22 runtime/cgo: use old-style indirect call on arm
TBR=elias.naur
CC=golang-dev
https://golang.org/cl/12943043
2013-08-14 14:54:08 -04:00
Dmitriy Vyukov
dd50dac56c runtime: fix windows build
R=golang-dev
CC=golang-dev
https://golang.org/cl/12941043
2013-08-14 22:18:49 +04:00
Dmitriy Vyukov
4e76abbc60 runtime: implement SysUnused on windows
Fixes #5584.

R=golang-dev, chaishushan, alex.brainman
CC=golang-dev
https://golang.org/cl/12720043
2013-08-14 21:54:07 +04:00
Dmitriy Vyukov
f8ca13c3e5 net: make TCPStress test shorter
It timeouts on freebsd builders:
http://build.golang.org/log/3d8169e13bff912bebf6fd3c54b34ad2d29a7221
but there are always runnable goroutines,
which suggests that it's slowly progressing.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12939043
2013-08-14 21:53:27 +04:00
Elias Naur
dc48e9516c runtime: Fix build on older ARM
The ARM external linking CL used BLX instructions in gcc assembler. Replace with BL to retain support on older ARM processors.

R=rsc
CC=golang-dev
https://golang.org/cl/12938043
2013-08-14 13:50:12 -04:00
Dmitriy Vyukov
9bbf1e1b72 net: make TestDeadlineRace shorter
1. Do less iterations in short mode
2. Bound number of times SetDeadline is executed

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12937043
2013-08-14 21:20:11 +04:00
Elias Naur
48c0d8b6e2 runtime: Fix netbsd/arm and freebsd/arm build
The ARM external linking CL left missed changes to sys_freebsd_arm.s and sys_netbsd_arm.s already done to sys_linux_arm.s.

R=rsc
CC=golang-dev
https://golang.org/cl/12842044
2013-08-14 13:18:32 -04:00
Matt Joiner
13c7896fb6 database/sql: fix accumulation of bad conns on prepared statements
Fixes an issue where prepared statements that outlive many
connections become expensive to invoke.

Fixes #6081

R=golang-dev
CC=bradfitz, golang-dev
https://golang.org/cl/12646044
2013-08-14 09:27:30 -07:00
Elias Naur
45233734e2 runtime.cmd/ld: Add ARM external linking and implement -shared in terms of external linking
This CL is an aggregate of 10271047, 10499043, 9733044. Descriptions of each follow:

10499043
runtime,cmd/ld: Merge TLS symbols and teach 5l about ARM TLS

This CL prepares for external linking support to ARM.

The pseudo-symbols runtime.g and runtime.m are merged into a single
runtime.tlsgm symbol. When external linking, the offset of a thread local
variable is stored at a memory location instead of being embedded into a offset
of a ldr instruction. With a single runtime.tlsgm symbol for both g and m, only
one such offset is needed.

The larger part of this CL moves TLS code from gcc compiled to internally
compiled. The TLS code now uses the modern MRC instruction, and 5l is taught
about TLS fallbacks in case the instruction is not available or appropriate.

10271047
This CL adds support for -linkmode external to 5l.

For 5l itself, use addrel to allow for D_CALL relocations to be handled by the
host linker. Of the cases listed in rsc's comment in issue 4069, only case 5 and
63 needed an update. One of the TODO: addrel cases was since replaced, and the
rest of the cases are either covered by indirection through addpool (cases with
LTO or LFROM flags) or stubs (case 74). The addpool cases are covered because
addpool emits AWORD instructions, which in turn are handled by case 11.

In the runtime, change the argv argument in the rt0* functions slightly to be a
pointer to the argv list, instead of relying on a particular location of argv.

9733044
The -shared flag to 6l outputs a shared library, implemented in Go
and callable from non-Go programs such as C.

The main part of this CL change the thread local storage model.
Go uses the fastest and least general mode, local exec. TLS data in shared
libraries normally requires at least the local dynamic mode, however, this CL
instead opts for using the initial exec mode. Initial exec mode is faster than
local dynamic mode and can be used in linux since the linker has reserved a
limited amount of TLS space for performance sensitive TLS code.

Initial exec mode requires an extra load from the GOT table to determine the
TLS offset. This penalty will not be paid if ld is not in -shared mode, since
TLS accesses will be reduced to local exec.

The elf sections .init_array and .rela.init_array are added to register the Go
runtime entry with cgo at library load time.

The "hidden" attribute is added to Cgo functions called from Go, since Go
does not generate call through the GOT table, and adding non-GOT relocations for
a global function is not supported by gcc. Cgo symbols don't need to be global
and avoiding the GOT table is also faster.

The changes to 8l are only removes code relevant to the old -shared mode where
internal linking was used.

This CL only address the low level linker work. It can be submitted by itself,
but to be useful, the runtime changes in CL 9738047 is also needed.

Design discussion at
https://groups.google.com/forum/?fromgroups#!topic/golang-nuts/zmjXkGrEx6Q

Fixes #5590.

R=rsc
CC=golang-dev
https://golang.org/cl/12871044
2013-08-14 15:38:54 +00:00
Dmitriy Vyukov
c92287686d runtime: improve block profiler support for channels
1. Handle select statements.
2. Handle chan close.
3. Show top frame in debug mode (chansend/chanrecv/selectgo).
Fixes #6049.

R=golang-dev, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/12694050
2013-08-14 13:56:01 +04:00
Russ Cox
883530c019 sync/atomic: fix new swap on arm linux
TBR=dvyukov
CC=golang-dev
https://golang.org/cl/12920043
2013-08-14 00:50:47 -04:00
Russ Cox
071e44e4e4 time: make Time implement encoding interfaces
See golang.org/s/go12encoding for design.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12706043
2013-08-14 00:34:00 -04:00
Russ Cox
413d4c6c11 net: make IP implement encoding.MarshalerText, encoding.UnmarshalerText
See golang.org/s/go12encoding for design.

R=golang-dev, bradfitz, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/12705043
2013-08-14 00:33:20 -04:00
Russ Cox
56ce83f7ba undo CL 12603044 / 2ca230b93195
fat fingers - did not intend to submit.
depends on the Unmarshaler CL anyway.

««« original CL description
encoding/xml: add, support Marshaler interface

See golang.org/s/go12xml for design.

Fixes #2771.
Fixes #4169.
Fixes #5975.
Fixes #6125.

R=golang-dev, iant, dan.kortschak
CC=golang-dev
https://golang.org/cl/12603044
»»»

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/12918043
2013-08-14 00:20:55 -04:00
Russ Cox
ce3ba126a0 encoding/gob: support new generic interfaces in package encoding
R=r
CC=golang-dev
https://golang.org/cl/12681044
2013-08-14 00:18:48 -04:00
Russ Cox
48b90bbc55 encoding: new package
See golang.org/s/go12encoding for design.

R=r
CC=golang-dev
https://golang.org/cl/12541051
2013-08-14 00:18:20 -04:00
Russ Cox
85f3acd788 encoding/xml: add, support Marshaler interface
See golang.org/s/go12xml for design.

Fixes #2771.
Fixes #4169.
Fixes #5975.
Fixes #6125.

R=golang-dev, iant, dan.kortschak
CC=golang-dev
https://golang.org/cl/12603044
2013-08-14 00:17:42 -04:00
Russ Cox
1a09d70e23 runtime: fix build on arm
Do not use ? :
I cannot say this enough.

TBR=dvyukov
CC=golang-dev
https://golang.org/cl/12903043
2013-08-13 19:37:54 -04:00
Brad Fitzpatrick
a2599cf50e archive/zip: add File.DataOffset
Accessor to find where the bytes of a file start.

R=golang-dev, rsc, dsymonds, adg
CC=golang-dev
https://golang.org/cl/12784045
2013-08-13 16:29:51 -07:00
Mikio Hara
45cb2e1b70 net: make Dial, Listen and ListenPacket return consistent error value
Update #4856

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12763044
2013-08-14 07:04:39 +09:00
Brad Fitzpatrick
ca3ed9f352 database/sql: add a disabled broken test
Update #6081

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/12810043
2013-08-13 14:56:40 -07:00
Brad Fitzpatrick
c7d352c941 archive/zip: remove an allocation, speed up a test
Update #6138

TestOver65kFiles spends all its time garbage collecting.
Removing the 1.4 MB of allocations per each of the 65k
files brings this from 34 seconds to 0.23 seconds.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12894043
2013-08-13 14:48:08 -07:00
Rob Pike
c18af467fd encoding/binary: make Write work like Read
Use the fast path calculation to shorten the code.
No effect on benchmarks.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12696046
2013-08-14 07:03:56 +10:00
Dmitriy Vyukov
992374f8fb net: fix build fix
Now builders say:
pkg/net/dnsclient_unix_test.go:10: imported and not used: "runtime"

R=golang-dev
CC=golang-dev
https://golang.org/cl/12890043
2013-08-14 00:55:18 +04:00
Dmitriy Vyukov
d90a81c39f net: fix windows build
Windows builders say:
pkg\net\dnsclient_unix_test.go:24: undefined: dnsConfig
pkg\net\dnsclient_unix_test.go:25: undefined: exchange

R=golang-dev
CC=golang-dev
https://golang.org/cl/12889043
2013-08-14 00:44:57 +04:00
Dmitriy Vyukov
4f2e382c9f runtime: dump scheduler state if GODEBUG=schedtrace is set
The schedtrace value sets dump period in milliseconds.
In default mode the trace looks as follows:
SCHED 0ms: gomaxprocs=4 idleprocs=0 threads=3 idlethreads=0 runqueue=0 [1 0 0 0]
SCHED 1001ms: gomaxprocs=4 idleprocs=3 threads=6 idlethreads=3 runqueue=0 [0 0 0 0]
SCHED 2008ms: gomaxprocs=4 idleprocs=1 threads=6 idlethreads=1 runqueue=0 [0 1 0 0]
If GODEBUG=scheddetail=1 is set as well, then the detailed trace is printed:
SCHED 0ms: gomaxprocs=4 idleprocs=0 threads=3 idlethreads=0 runqueue=0 singleproc=0 gcwaiting=1 mlocked=0 nmspinning=0 stopwait=0 sysmonwait=0
  P0: status=3 tick=1 m=0 runqsize=1/128 gfreecnt=0
  P1: status=3 tick=0 m=-1 runqsize=0/128 gfreecnt=0
  P2: status=3 tick=0 m=-1 runqsize=0/128 gfreecnt=0
  P3: status=3 tick=0 m=-1 runqsize=0/128 gfreecnt=0
  M2: p=-1 curg=-1 mallocing=0 throwing=0 gcing=0 locks=1 dying=0 helpgc=0 spinning=0 lockedg=-1
  M1: p=-1 curg=-1 mallocing=0 throwing=0 gcing=0 locks=1 dying=0 helpgc=0 spinning=0 lockedg=-1
  M0: p=0 curg=1 mallocing=0 throwing=0 gcing=0 locks=1 dying=0 helpgc=0 spinning=0 lockedg=1
  G1: status=2() m=0 lockedm=0
  G2: status=1() m=-1 lockedm=-1

R=golang-dev, raggi, rsc
CC=golang-dev
https://golang.org/cl/11435044
2013-08-14 00:30:55 +04:00
Russ Cox
2642c6e24d sync/atomic: update comment for ARM 64-bit atomics
They don't work on older chips, just like the x86-32 64-bit atomics.

Update #6134

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12880043
2013-08-13 16:16:05 -04:00
Keith Randall
74e78df107 undo CL 12840043 / 3b9f54db72a1
Breaks the build.  Old bucket arrays kept by iterators
still need to be scanned.

««« original CL description
runtime: tell GC not to scan internal hashmap structures.
We'll do it ourselves via hash_gciter, thanks.
Fixes bug 6119.

R=golang-dev, dvyukov, cookieo9, rsc
CC=golang-dev
https://golang.org/cl/12840043
»»»

R=golang-dev
CC=golang-dev
https://golang.org/cl/12884043
2013-08-13 12:59:39 -07:00
Keith Randall
0df438c683 runtime: tell GC not to scan internal hashmap structures.
We'll do it ourselves via hash_gciter, thanks.
Fixes bug 6119.

R=golang-dev, dvyukov, cookieo9, rsc
CC=golang-dev
https://golang.org/cl/12840043
2013-08-13 12:36:03 -07:00
Russ Cox
ba14974e07 undo CL 12787044 / ed695cdf962b
The NetBSD and OpenBSD failures are apparently real,
not due to the test bug fixed in 100b9fc0c46f.

««« original CL description
runtime/pprof: test netbsd and openbsd again

Maybe these will work now.

R=golang-dev, dvyukov, bradfitz
CC=golang-dev
https://golang.org/cl/12787044
»»»

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12873043
2013-08-13 23:33:49 +04:00
Dmitriy Vyukov
4961483e7d runtime: fix LockOSThread
Fixes #6100.

R=golang-dev, dave, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/12703045
2013-08-13 22:37:04 +04:00
Dmitriy Vyukov
f9066fe1c0 runtime: more reliable preemption
Currently it's possible that a goroutine
that periodically executes non-blocking
cgo/syscalls is never preempted.
This change splits scheduler and syscall
ticks to prevent such situation.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12658045
2013-08-13 22:14:04 +04:00
Dmitriy Vyukov
cc4e6aad8e runtime: do no lose CPU profiling signals
Currently we lose lots of profiling signals.
Most notably, GC is not accounted at all.
But stack splits, scheduler, syscalls, etc are lost as well.
This creates seriously misleading profile.
With this change all profiling signals are accounted.
Now I see these additional entries that were previously absent:
161  29.7%  29.7%      164  30.3% syscall.Syscall
 12   2.2%  50.9%       12   2.2% scanblock
 11   2.0%  55.0%       11   2.0% markonly
 10   1.8%  58.9%       10   1.8% sweepspan
  2   0.4%  85.8%        2   0.4% runtime.newstack
It is still impossible to understand what causes stack splits,
but at least it's clear how many time is spent on them.
Update #2197.
Update #5659.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12179043
2013-08-13 22:12:02 +04:00
Dmitriy Vyukov
1da1030b5d runtime: fix false deadlock crash
Fixes #6070.
Update #6055.

R=golang-dev, nightlyone, rsc
CC=golang-dev
https://golang.org/cl/12602043
2013-08-13 22:07:42 +04:00
Dmitriy Vyukov
7eb6a6f46d sync/atomic: fix ARM nomenclature in comments
R=cshapiro
CC=golang-dev
https://golang.org/cl/12877043
2013-08-13 22:07:21 +04:00
Rick Arnold
4be93851c3 io: prevent write to PipeWriter after Close
Return an ErrClosedPipe rather than allowing the write to proceed.

Fixes #5330.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12541053
2013-08-13 11:04:09 -07:00
Dmitriy Vyukov
d3f36dbfc7 sync/atomic: add Swap to nil deref test
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12870043
2013-08-13 21:18:33 +04:00
Dmitriy Vyukov
66c58cea67 sync/atomic: trigger paging fault early on linux/arm
so that we don't need to traceback through __kuser_cmpxchg

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12869043
2013-08-13 21:15:47 +04:00
Alex A Skinner
0a3cb7ece3 net: implement DNS TCP fallback query if UDP response is truncated
Fixes #5686.

R=golang-dev, bradfitz, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/12458043
2013-08-13 09:44:12 -07:00
Russ Cox
469250fb77 runtime/pprof: test netbsd and openbsd again
Maybe these will work now.

R=golang-dev, dvyukov, bradfitz
CC=golang-dev
https://golang.org/cl/12787044
2013-08-13 12:35:37 -04:00
Dmitriy Vyukov
71c6da39ce runtime/pprof: fix test
R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/12790043
2013-08-13 12:18:29 -04:00
Dmitriy Vyukov
aaab946943 runtime: fix handling of network deadlines
Ensure that deadlines affect already issued IO.

R=golang-dev, mikioh.mikioh, bradfitz
CC=golang-dev
https://golang.org/cl/12847043
2013-08-13 19:11:42 +04:00
Dmitriy Vyukov
0e15b03f93 sync/atomic: add Swap functions
Fixes #5722.

R=golang-dev, khr, cshapiro, rsc, r
CC=golang-dev
https://golang.org/cl/12670045
2013-08-13 15:26:48 +04:00
Mikio Hara
39a7017c26 net: make deadline helpers join to netFD as its methods
Just for readability reasons; to prevent overlooking deadline stuff
across over platforms.

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/8656044
2013-08-13 20:00:58 +09:00
Dmitriy Vyukov
5a20b4a6a9 sync: faster Cond
The new version does not require any memory allocations and is 30-50% faster.
Also detect and painc if Cond is copied after first.

benchmark            old ns/op    new ns/op    delta
BenchmarkCond1             317          195  -38.49%
BenchmarkCond1-2           875          607  -30.63%
BenchmarkCond1-4          1116          548  -50.90%
BenchmarkCond1-8          1013          613  -39.49%
BenchmarkCond1-16          983          450  -54.22%
BenchmarkCond2             559          352  -37.03%
BenchmarkCond2-2          1916         1378  -28.08%
BenchmarkCond2-4          1518         1322  -12.91%
BenchmarkCond2-8          2313         1291  -44.19%
BenchmarkCond2-16         1885         1078  -42.81%
BenchmarkCond4            1070          614  -42.62%
BenchmarkCond4-2          4899         3047  -37.80%
BenchmarkCond4-4          3813         3006  -21.16%
BenchmarkCond4-8          3605         3045  -15.53%
BenchmarkCond4-16         4148         2637  -36.43%
BenchmarkCond8            2086         1264  -39.41%
BenchmarkCond8-2          9961         6736  -32.38%
BenchmarkCond8-4          8135         7689   -5.48%
BenchmarkCond8-8          9623         7517  -21.89%
BenchmarkCond8-16        11661         8093  -30.60%

R=sougou, rsc, bradfitz, r
CC=golang-dev
https://golang.org/cl/11573043
2013-08-13 14:45:36 +04:00
Dmitriy Vyukov
d1b66439f9 runtime: eliminate excessive notewakeup calls in timers
If the timer goroutine is wakeup by timeout,
other goroutines will still notewakeup because sleeping is still set.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12763043
2013-08-13 14:14:24 +04:00
Dmitriy Vyukov
e33e476e07 syscall: disable cpu profiling around fork
Fixes #5517.
Fixes #5659.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12183044
2013-08-13 13:01:30 +04:00
Dmitriy Vyukov
9707f269c1 runtime: fix network timers related crash
Fixes #6103.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/12686045
2013-08-13 12:55:57 +04:00
David Symonds
c272fd14a8 go/doc: permit a package synopsis to end with ":\n".
R=gri, r
CC=golang-dev
https://golang.org/cl/12822043
2013-08-13 16:20:17 +10:00
Rob Pike
954d14741d go/build: change the wording of NoGoError and comment it better
Out of context, it can be very confusing because there can be lots of Go
files in the directory, but the error message says there aren't.

R=golang-dev, dsymonds, rsc
CC=golang-dev
https://golang.org/cl/12823043
2013-08-13 11:32:32 +10:00
Elias Naur
83348a13fb text/template: Make function call builtin handle nil errors correctly
The call builtin unconditionally tries to convert a second return value from a function to the error type. This fails in case nil is returned, effectively making call useless for functions returning two values.

This CL adds a nil check for the second return value, and adds a test.

Note that for regular function and method calls the nil error case is handled correctly and is verified by a test.

R=r
CC=golang-dev
https://golang.org/cl/12804043
2013-08-13 11:11:05 +10:00
Volker Dobler
4f86a96ac9 net/http: do not send malformed cookie domain attribute
Malformed domain attributes are not sent in a Set-Cookie header.
Instead the domain attribute is dropped which turns the cookie
into a host-only cookie. This is much safer than dropping characters
from domain attribute.

Domain attributes with a leading dot '.' are still allowed, even
if discouraged by RFC 6265 section 4.1.1.

Fixes #6013

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12745043
2013-08-12 15:14:34 -07:00
Keith Randall
e838334beb runtime: change textflags from numbers to symbols
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12798043
2013-08-12 13:47:18 -07:00
Dmitriy Vyukov
2791ef0b67 runtime/race: add end-to-end test
Fixes #5933.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12699051
2013-08-12 22:04:10 +04:00
Dmitriy Vyukov
fa4628346b runtime: remove unused m->racepc
The original plan was to collect allocation stacks
for all memory blocks. But it was never implemented
and it's not in near plans and it's unclear how to do it at all.

R=golang-dev, dave, bradfitz
CC=golang-dev
https://golang.org/cl/12724044
2013-08-12 21:48:19 +04:00
Dmitriy Vyukov
f3c1070fa4 sync/atomic: specify argsize for asm routines
Fixes #6098.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12717043
2013-08-12 21:46:33 +04:00
Dmitriy Vyukov
92254d4463 runtime: fix ARM assembly formatting
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12702048
2013-08-12 21:36:33 +04:00
Keith Randall
8b789e1738 all: change textflags from numbers to symbols.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12774043
2013-08-12 10:25:36 -07:00
Keith Randall
1f7966346e math: convert textflags from numbers to symbols
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12773044
2013-08-12 10:25:18 -07:00
Keith Randall
db324ccd72 syscall: Convert textflags from numbers to symbols.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12773043
2013-08-12 10:24:30 -07:00
Andrew Gerrand
8eb8ad2454 bufio: add Writer example
Update #5530

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12504044
2013-08-12 13:03:50 +10:00
Rob Pike
6b706cf50d bufio: make it clear that the client must call Writer.Flush
Fixes #5530.

R=golang-dev, iant, com.liigo
CC=golang-dev
https://golang.org/cl/12688044
2013-08-12 12:55:33 +10:00
Rob Pike
ce00562607 crypto/rand: simplify example to exploit properties of ReadFull
No need for the complex condition.
Fixes #6089

R=golang-dev, mischief, adg
CC=golang-dev
https://golang.org/cl/12731043
2013-08-12 12:52:23 +10:00
Dmitriy Vyukov
2758101b9d runtime/pprof: add block profile test
Fixes #5993.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12665046
2013-08-11 13:05:51 +04:00
Brad Fitzpatrick
3e38b7f246 net/http: simplify server, use bufio Reader.Reset and Writer.Reset
Update #5100
Update #6086

Remove switchReader, switchWriter, switchReaderPair,
switchWriterPair, etc.

Now it only maintains pools of bufio Readers and Writers, but
uses Reset instead of working around all their
previously-associated state.

Compared to before the bufio Reset change, it's the same number of
allocations, and also faster:

benchmark                                   old ns/op    new ns/op    delta
BenchmarkClientServer                          111218       109828   -1.25%
BenchmarkClientServerParallel4                  70580        70013   -0.80%
BenchmarkClientServerParallel64                 72636        68919   -5.12%
BenchmarkServer                                139858       137068   -1.99%
BenchmarkServerFakeConnNoKeepAlive              14619        14314   -2.09%
BenchmarkServerFakeConnWithKeepAlive            12390        11361   -8.31%
BenchmarkServerFakeConnWithKeepAliveLite         7630         7306   -4.25%
BenchmarkServerHandlerTypeLen                    9688         9342   -3.57%
BenchmarkServerHandlerNoLen                      8700         8470   -2.64%
BenchmarkServerHandlerNoType                     9255         8949   -3.31%
BenchmarkServerHandlerNoHeader                   7058         6806   -3.57%

benchmark                                  old allocs   new allocs    delta
BenchmarkClientServer                              61           61    0.00%
BenchmarkClientServerParallel4                     61           61    0.00%
BenchmarkClientServerParallel64                    61           61    0.00%
BenchmarkServer                                    16           16    0.00%
BenchmarkServerFakeConnNoKeepAlive                 24           24    0.00%
BenchmarkServerFakeConnWithKeepAlive               19           19    0.00%
BenchmarkServerFakeConnWithKeepAliveLite            9            9    0.00%
BenchmarkServerHandlerTypeLen                      17           17    0.00%
BenchmarkServerHandlerNoLen                        14           14    0.00%
BenchmarkServerHandlerNoType                       15           15    0.00%
BenchmarkServerHandlerNoHeader                      9            9    0.00%

benchmark                                   old bytes    new bytes    delta
BenchmarkClientServer                            6988         6985   -0.04%
BenchmarkClientServerParallel4                   6979         6985    0.09%
BenchmarkClientServerParallel64                  7002         7019    0.24%
BenchmarkServer                                  1846         1848    0.11%
BenchmarkServerFakeConnNoKeepAlive               2420         2412   -0.33%
BenchmarkServerFakeConnWithKeepAlive             2126         2129    0.14%
BenchmarkServerFakeConnWithKeepAliveLite          989          990    0.10%
BenchmarkServerHandlerTypeLen                    1818         1819    0.06%
BenchmarkServerHandlerNoLen                      1775         1777    0.11%
BenchmarkServerHandlerNoType                     1783         1785    0.11%
BenchmarkServerHandlerNoHeader                    989          990    0.10%

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12708046
2013-08-10 19:22:44 -07:00
Brad Fitzpatrick
ede9aa9e02 bufio: drop buffer recycling, add Reader.Reset and Writer.Reset
Fixes #6086

R=golang-dev, pieter, r, rsc
CC=golang-dev
https://golang.org/cl/12603049
2013-08-10 19:22:19 -07:00
ChaiShushan
418e2f6aae strconv: fix typo in docs
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12709044
2013-08-10 11:38:42 +10:00
Mikio Hara
db84a450d7 net: move InvalidAddrError type into net.go
Probably we should remove this type before Go 1 contract has settled,
but too late. Instead, keep InvalidAddrError close to package generic
error types.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12670044
2013-08-10 09:46:22 +09:00
Carl Shapiro
abc516e420 cmd/cc, cmd/gc, runtime: Uniquely encode iface and eface pointers in the pointer map.
Prior to this change, pointer maps encoded the disposition of
a word using a single bit.  A zero signaled a non-pointer
value and a one signaled a pointer value.  Interface values,
which are a effectively a union type, were conservatively
labeled as a pointer.

This change widens the logical element size of the pointer map
to two bits per word.  As before, zero signals a non-pointer
value and one signals a pointer value.  Additionally, a two
signals an iface pointer and a three signals an eface pointer.

Following other changes to the runtime, values two and three
will allow a type information to drive interpretation of the
subsequent word so only those interface values containing a
pointer value will be scanned.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12689046
2013-08-09 16:48:12 -07:00
Rob Pike
556b337ece encoding/binary: better description for intReadSize
It used to be called intDestSize; the new name is better too.

R=bradfitz
CC=golang-dev
https://golang.org/cl/12713043
2013-08-10 09:11:58 +10:00
Rob Pike
1f25f5ad48 encoding/binary: fast path for reading slices
Again, it still allocates but the code is simple.

benchmark                       old ns/op    new ns/op    delta
BenchmarkReadSlice1000Int32s        35580        11465  -67.78%

benchmark                        old MB/s     new MB/s  speedup
BenchmarkReadSlice1000Int32s       112.42       348.86    3.10x

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12694048
2013-08-10 08:40:32 +10:00
Russ Cox
d9f93b0e0b go/build: add AllTags to Package
AllTags lists all the tags that can affect the decision
about which files to include. Tools scanning packages
can use this to decide how many variants there are
and what they are.

R=bradfitz
CC=golang-dev
https://golang.org/cl/12703044
2013-08-09 18:34:08 -04:00
Russ Cox
080e00d55d encoding/json: escape & always
There are a few different places in the code that escape
possibly-problematic characters like < > and &.
This one was the only one missing &, so add it.

This means that if you Marshal a string, you get the
same answer you do if you Marshal a string and
pass it through the compactor. (Ironically, the
compaction makes the string longer.)

Because html/template invokes json.Marshal to
prepare escaped strings for JavaScript, this changes
the form of some of the escaped strings, but not
their meaning.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12708044
2013-08-09 18:33:57 -04:00
Taru Karttunen
e3dbb1a310 net/http: Make ReadResponse work with a nil Request parameter
Fixes #5583

R=golang-dev, dave, bradfitz
CC=golang-dev
https://golang.org/cl/9821043
2013-08-09 15:11:03 -07:00
Nicolas Owens
3319db4c94 net: fix LookupSRV ordering on plan 9
lookup_plan9.go's lookupSRV is using the wrong order for srv results. order should be weight, priority, port, following the response from /net/dns:

  chi Aug  9 20:31:13 Rread tag 20 count 61 '_xmpp-client._tcp.offblast.org srv 5 0 5222 iota.offblast.org' 72

R=golang-dev, bradfitz
CC=ality, golang-dev, r, rsc
https://golang.org/cl/12708043
2013-08-09 14:16:43 -07:00
Pieter Droogendijk
b990c40d5e mime: escape backslash in attribute values
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12689045
2013-08-09 13:10:53 -07:00
Pieter Droogendijk
14903f6598 strings: add test for Count
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12541050
2013-08-09 12:51:21 -07:00
Brad Fitzpatrick
ecf3274143 io/ioutil: add WriteString to Discard
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/12580045
2013-08-09 11:27:29 -07:00
Dmitriy Vyukov
cc0a005c9d runtime: fix netbsd build
I've placed net.runtime_Semacquire into netpoll.goc,
but netbsd does not yet use netpoll.goc.

R=golang-dev, bradfitz, iant
CC=golang-dev
https://golang.org/cl/12699045
2013-08-09 22:17:12 +04:00
Dmitriy Vyukov
23e15f7253 net: add special netFD mutex
The mutex, fdMutex, handles locking and lifetime of sysfd,
and serializes Read and Write methods.
This allows to strip 2 sync.Mutex.Lock calls,
2 sync.Mutex.Unlock calls, 1 defer and some amount
of misc overhead from every network operation.

On linux/amd64, Intel E5-2690:
benchmark                             old ns/op    new ns/op    delta
BenchmarkTCP4Persistent                    9595         9454   -1.47%
BenchmarkTCP4Persistent-2                  8978         8772   -2.29%
BenchmarkTCP4ConcurrentReadWrite           4900         4625   -5.61%
BenchmarkTCP4ConcurrentReadWrite-2         2603         2500   -3.96%

In general it strips 70-500 ns from every network operation depending
on processor model. On my relatively new E5-2690 it accounts to ~5%
of network op cost.

Fixes #6074.

R=golang-dev, bradfitz, alex.brainman, iant, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/12418043
2013-08-09 21:43:00 +04:00
Brad Fitzpatrick
89b5c6c0af encoding/json: faster encoding
The old code was caching per-type struct field info. Instead,
cache type-specific encoding funcs, tailored for that
particular type to avoid unnecessary reflection at runtime.
Once the machine is built once, future encodings of that type
just run the func.

benchmark               old ns/op    new ns/op    delta
BenchmarkCodeEncoder     48424939     36975320  -23.64%

benchmark                old MB/s     new MB/s  speedup
BenchmarkCodeEncoder        40.07        52.48    1.31x

Additionally, the numbers seem stable now at ~52 MB/s, whereas
the numbers for the old code were all over the place: 11 MB/s,
40 MB/s, 13 MB/s, 39 MB/s, etc.  In the benchmark above I compared
against the best I saw the old code do.

R=rsc, adg
CC=gobot, golang-dev, r
https://golang.org/cl/9129044
2013-08-09 09:46:47 -07:00
Ian Lance Taylor
ba6cf63cba net: give C.getaddrinfo a hint that we only want SOCK_STREAM answers
This should be more efficient everywhere, and appears to be
required on Solaris.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12583046
2013-08-09 09:23:27 -07:00
Rob Pike
ef86beb445 encoding/binary: fix 32-bit build
Sigh.

R=golang-dev
CC=golang-dev
https://golang.org/cl/12491045
2013-08-09 23:23:34 +10:00
Rob Pike
c0465d0326 encoding/binary: speed up writing slices of integers
Simple approach. Still generates garbage, but not as much.

benchmark                        old ns/op    new ns/op    delta
BenchmarkWriteSlice1000Int32s        40260        18791  -53.33%

benchmark                         old MB/s     new MB/s  speedup
BenchmarkWriteSlice1000Int32s        99.35       212.87    2.14x

Fixes #2634.

R=golang-dev, crawshaw
CC=golang-dev
https://golang.org/cl/12680046
2013-08-09 23:15:08 +10:00
Dmitriy Vyukov
01f1e3da48 runtime: traceback running goroutines
Introduce freezetheworld function that is a best-effort attempt to stop any concurrently running goroutines. Call it during crash.
Fixes #5873.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12054044
2013-08-09 12:53:35 +04:00
Rob Pike
e0405b7318 encoding/binary: document its goals better
It's a modest package with modest goals and limitations.
Make that clear.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12694043
2013-08-09 17:08:02 +10:00
Pieter Droogendijk
f2bc275525 encoding/csv: always allow trailing commas
Original CL by rsc (11916045):

The motivation for disallowing them was RFC 4180 saying
"The last field in the record must not be followed by a comma."
I believe this is an admonition to CSV generators, not readers.
When reading, anything followed by a comma is not the last field.

Fixes #5892.

R=golang-dev, rsc, r
CC=golang-dev
https://golang.org/cl/12294043
2013-08-09 15:46:01 +10:00
Rob Pike
b7eb0e5990 text/template/parse: nicer error when comment ends before final delimiter
By separating finding the end of the comment from the end of the action,
we can diagnose malformed comments better.
Also tweak the documentation to make the comment syntax clearer.

Fixes #6022.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12570044
2013-08-09 12:57:21 +10:00
Rob Pike
94179d61ab reflect: avoid allocation when interface's contents are not addressable
See issue 4949 for a full explanation.

Allocs go from 1 to zero in the non-addressable case.
Fixes #4949.

BenchmarkInterfaceBig             90           14  -84.01%
BenchmarkInterfaceSmall           14           14   +0.00%

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12646043
2013-08-09 10:49:01 +10:00
David Symonds
d2bff757f6 net/mail: comment our divergence from RFC 5322.
R=golang-dev, bradfitz
CC=golang-dev, ryanslade
https://golang.org/cl/12588044
2013-08-09 10:17:57 +10:00
Mikio Hara
554d47ecb5 net: separate unix pollster initialization from network file descriptor allocation
Unlike the existing net package own pollster, runtime-integrated
network pollster on BSD variants, actually kqueue, requires a socket
that has beed passed to syscall.Listen previously for a stream
listener.

This CL separates pollDesc.Init of Unix network pollster from newFD
to avoid any breakages in the transition from Unix network pollster
to runtime-integrated pollster. Upcoming CLs will rearrange the call
order of pollster and syscall functions like the following;

- For dialers that open active connections, pollDesc.Init will be
  called in between syscall.Bind and syscall.Connect.

- For stream listeners that open passive stream connections,
  pollDesc.Init will be called just after syscall.Listen.

- For datagram listeners that open datagram connections,
  pollDesc.Init will be called just after syscall.Bind.

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

Update #5199

R=dvyukov, bradfitz
CC=golang-dev
https://golang.org/cl/12663043
2013-08-09 09:02:27 +09:00
Volker Dobler
654f35865f net: avoid string operation and make valid domain names explicit
Having a trailing dot in the string doesn't really simplify
the checking loop in isDomainName. Avoid this unnecessary allocation.
Also make the valid domain names more explicit by adding some more
test cases.

benchmark            old ns/op    new ns/op    delta
BenchmarkDNSNames       2420.0        983.0  -59.38%

benchmark           old allocs   new allocs    delta
BenchmarkDNSNames           12            0  -100.00%

benchmark            old bytes    new bytes    delta
BenchmarkDNSNames          336            0  -100.00%

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12662043
2013-08-08 16:33:57 -07:00
Brad Fitzpatrick
de04bf24e5 net/http: fix early side effects in the ResponseWriter's ReadFrom
The ResponseWriter's ReadFrom method was causing side effects on
the output before any data was read.

Now, bail out early and do a normal copy (which does a read
before writing) when our input and output are known to not to
be the pair of types we need for sendfile.

Fixes #5660

R=golang-dev, rsc, nightlyone
CC=golang-dev
https://golang.org/cl/12632043
2013-08-08 14:02:54 -07:00
Brad Fitzpatrick
8378804640 os: fix windows and plan9 builds
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12519046
2013-08-08 11:13:00 -07:00
Dmitriy Vyukov
9f46efce52 runtime: print scavenger details when forced with debug.FreeOSMemory
Fixes #5900.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12669043
2013-08-08 21:55:04 +04:00
Pieter Droogendijk
bdbd5418f4 os: make Readdir work as documented
Readdir's result should never contain a nil.

Fixes #5960.

R=golang-dev, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/12261043
2013-08-08 10:44:01 -07:00
Dmitriy Shelenin
547f1a6fe7 encoding/xml: allow attributes stored in pointers to be marshaled.
Fixes #5334.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/8653047
2013-08-08 10:40:51 -07:00
Ryan Slade
73b8baa1bd net/mail: AddressList fails to parse addresses with a dot
Fixes #4938.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12657044
2013-08-08 10:00:24 -07:00
Dmitriy Vyukov
65834685d3 runtime: use GetQueuedCompletionStatusEx on windows if available
GetQueuedCompletionStatusEx allows to dequeue a batch of completion
notifications, which is more efficient than dequeueing one by one.

benchmark                           old ns/op    new ns/op    delta
BenchmarkClientServerParallel4         100605        90945   -9.60%
BenchmarkClientServerParallel4-2        90225        74504  -17.42%

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/12436044
2013-08-08 17:41:57 +04:00
Dmitriy Vyukov
ed8c5501c7 net: use SetFileCompletionNotificationModes on windows if available
This allows to skip GetQueuedCompletionStatus if an IO operation completes synchronously.
benchmark                    old ns/op    new ns/op    delta
BenchmarkTCP4Persistent          27669        25863   -6.53%
BenchmarkTCP4Persistent-2        18173        15908  -12.46%
BenchmarkTCP4Persistent-4        10390         9766   -6.01%

R=golang-dev, mikioh.mikioh, alex.brainman
CC=golang-dev
https://golang.org/cl/12409044
2013-08-08 17:36:43 +04:00
Rob Pike
b4f370ca57 regexp/syntax: make it clearer that \b and \B are ASCII-defined
Fixes #5896.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12645043
2013-08-08 13:26:39 +10:00
Rob Pike
077989cf94 container/list: fix typo in comment
Fixes #6058.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12643043
2013-08-08 12:41:19 +10:00
Rob Pike
6ac93e2ac8 flag: export commandLine, the previously internal default FlagSet
s/commandLine/CommandLine/g

Fixes #4209.

R=golang-dev, dsymonds, bradfitz
CC=golang-dev
https://golang.org/cl/12587043
2013-08-08 11:50:58 +10:00
Keith Randall
a97a91de06 runtime: Record jmpdefer's argument size.
Fixes bug 6055.

R=golang-dev, bradfitz, dvyukov, khr
CC=golang-dev
https://golang.org/cl/12536045
2013-08-07 14:03:50 -07:00
Dmitriy Vyukov
326ae8d14e runtime: fix traceback in cgo programs
Fixes #6061.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12609043
2013-08-08 00:31:52 +04:00
Dmitriy Vyukov
1590abef03 runtime: do not run TestCgoSignalDeadlock on windows in short mode
The test takes up to 64 seconds on windows builders.
I've tried to reduce number of iterations in the test,
but it does not affect run time.
Fixes #6054.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/12531043
2013-08-08 00:04:28 +04:00
Carl Shapiro
73c93a404c cmd/cc, cmd/gc, runtime: emit bitmaps for scanning locals.
Previously, all word aligned locations in the local variables
area were scanned as conservative roots.  With this change, a
bitmap is generated describing the locations of pointer values
in local variables.

With this change the argument bitmap information has been
changed to only store information about arguments.  The locals
member, has been removed.  In its place, the bitmap data for
local variables is now used to store the size of locals.  If
the size is negative, the magnitude indicates the size of the
local variables area.

R=rsc
CC=golang-dev
https://golang.org/cl/12328044
2013-08-07 12:47:01 -07:00
Keith Randall
0273dc131e runtime: convert .s textflags from numbers to symbolic constants.
Remove NOPROF/DUPOK from everything.

Edits done with a script, except pclinetest.asm which depended
on the DUPOK flag on main().

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12613044
2013-08-07 12:20:05 -07:00
Pieter Droogendijk
a08b1d13ea net/http: Various fixes to Basic authentication
There were some issues with the code sometimes using base64.StdEncoding,
and sometimes base64.URLEncoding.
Encoding basic authentication is now always done by the same code.

Fixes #5970.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12397043
2013-08-07 11:58:59 -07:00
Keith Randall
5a54696d78 cmd/ld: Put the textflag constants in a separate file.
We can then include this file in assembly to replace
cryptic constants like "7" with meaningful constants
like "(NOPROF|DUPOK|NOSPLIT)".

Converting just pkg/runtime/asm*.s for now.  Dropping NOPROF
and DUPOK from lots of places where they aren't needed.
More .s files to come in a subsequent changelist.

A nonzero number in the textflag field now means
"has not been converted yet".

R=golang-dev, daniel.morsing, rsc, khr
CC=golang-dev
https://golang.org/cl/12568043
2013-08-07 10:23:24 -07:00
Alex Brainman
60aa48c127 net: fix small bug introduced by 48f7c4dd87fe
Fixes #6063

R=golang-dev, r, dave
CC=dvyukov, golang-dev
https://golang.org/cl/12586043
2013-08-07 13:36:41 +10:00
Josh Bleecher Snyder
1535727e57 net/http: do not send redundant Connection: close header in HTTP/1.0 responses
HTTP/1.0 connections are closed implicitly, unless otherwise specified.

Note that this change does not test or fix "request too large" responses.
Reasoning: (a) it complicates tests and fixes, (b) they should be rare,
and (c) this is just a minor wire optimization, and thus not really worth worrying
about in this context.

Fixes #5955.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12435043
2013-08-06 18:37:34 -07:00
Brad Fitzpatrick
ebe91d1105 net/http: treat HEAD requests like GET requests
A response to a HEAD request is supposed to look the same as a
response to a GET request, just without a body.

HEAD requests are incredibly rare in the wild.

The Go net/http package has so far treated HEAD requests
specially: a Write on our default ResponseWriter returned
ErrBodyNotAllowed, telling handlers that something was wrong.
This was to optimize the fast path for HEAD requests, but:

1) because HEAD requests are incredibly rare, they're not
   worth having a fast path for.

2) Letting the http.Handler handle but do nop Writes is still
   very fast.

3) this forces ugly error handling into the application.
   e.g. https://code.google.com/p/go/source/detail?r=6f596be7a31e
   and related.

4) The net/http package nowadays does Content-Type sniffing,
   but you don't get that for HEAD.

5) The net/http package nowadays does Content-Length counting
   for small (few KB) responses, but not for HEAD.

6) ErrBodyNotAllowed was useless. By the time you received it,
   you had probably already done all your heavy computation
   and I/O to calculate what to write.

So, this change makes HEAD requests like GET requests.

We now count content-length and sniff content-type for HEAD
requests. If you Write, it doesn't return an error.

If you want a fast-path in your code for HEAD, you have to do
it early and set all the response headers yourself. Just like
before. If you choose not to Write in HEAD requests, be sure
to set Content-Length if you know it. We won't write
"Content-Length: 0" because you might've just chosen to not
write (or you don't know your Content-Length in advance).

Fixes #5454

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12583043
2013-08-06 18:33:03 -07:00
Rob Pike
a4ebad79b4 all: fix up language in a couple of comments
Leftovers from 11699043

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12558046
2013-08-07 09:35:06 +10:00
Rob Pike
f59064de80 fmt: fix up zero padding
If the padding is huge, we crashed by blowing the buffer. That's easy: make sure
we have a big enough buffer by allocating in problematic cases.
Zero padding floats was just wrong in general: the space would appear in the
middle.

Fixes #6044.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12498043
2013-08-07 08:38:46 +10:00
Brad Fitzpatrick
1104a2afb1 strings: add IndexByte benchmark
Like existing Index, IndexRune, IndexHardN, etc.

R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/12486044
2013-08-06 14:41:07 -07:00
Keith Randall
12e46e42ec runtime: don't mark the new call trampolines as NOSPLIT.
They may call other NOSPLIT routines, and that might
overflow the stack.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12563043
2013-08-06 14:33:55 -07:00
Mikio Hara
b29d035fe6 net: add dial, listenStream and listenDatagram methods to netFD
This CL refactors the existing listenerSockaddr function into several
methods on netFD.

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

Update #5199

R=golang-dev, dave, alex.brainman, dvyukov, remyoudompheng
CC=golang-dev
https://golang.org/cl/12023043
2013-08-07 06:15:50 +09:00
Rob Pike
98a80b95b4 runtime: use correct types for maxstring and concatstring
Updates #6046.
This CL just does maxstring and concatstring. There are other functions
to fix but doing them a few at a time will help isolate any (unlikely)
breakages these changes bring up in architectures I can't test
myself.

R=golang-dev, dave, iant
CC=golang-dev
https://golang.org/cl/12519044
2013-08-07 06:49:11 +10:00
Brad Fitzpatrick
ad119b9c4d os: fix plan9 build
I broke it with the darwin getwd attrlist stuff (0583e9d36dd).
plan9 doesn't have syscall.ENOTSUP.

It's in api/go1.txt as a symbol always available (not context-specific):

pkg syscall, const ENOTSUP Errno

... but plan9 isn't considered by cmd/api, so it only looks
universally available.  Alternatively, we could add a fake ENOTSUP
to plan9, but they were making efforts earlier to clean their
syscall package, so I'd prefer not to dump more in it.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12509044
2013-08-06 12:04:08 -07:00
Dustin Sallings
9115345925 archive/zip: allow user-extensible compression methods
This change replaces the hard-coded switch on compression method
in zipfile reader and writer with a map into which users can
register compressors and decompressors in their init()s.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/12421043
2013-08-06 12:03:38 -07:00
Russ Cox
8dc7a31d77 runtime/pprof: adjust test
NetBSD and OpenBSD are broken like OS X is. Good to know.

Drop required count from avg/2 to avg/3, because the
Plan 9 builder just barely missed avg/2 in one of its runs.

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/12548043
2013-08-06 14:49:55 -04:00
Dmitriy Vyukov
905f296552 net: test that Read/Write do 0 allocations
It turned out that change 12413043 did not break
any builders. So let's lock this in.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12545043
2013-08-06 21:29:35 +04:00
Mikio Hara
262d6f58c7 syscall: fix IPv6 wrong network mask on latest FreeBSD
Looks like latest FreeBSD doesn't set address family identifer
for RTAX_NETMASK stuff; probably RTAX_GENMASK too, not confirmed.
This CL tries to identify address families by using the length of
each socket address if possible.

The issue is confirmed on FreeBSD 9.1.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12332043
2013-08-07 00:25:23 +09:00
Mikio Hara
6a76bca362 net: separate pollster initialization from network file descriptor allocation
Unlike the existing net package own pollster, runtime-integrated
network pollster on BSD variants, actually kqueue, requires a socket
that has beed passed to syscall.Listen previously for a stream
listener.

This CL separates pollDesc.Init (actually runtime_pollOpen) from newFD
to allow control of each state of sockets and adds init method to netFD
instead. Upcoming CLs will rearrange the call order of runtime-integrated
pollster and syscall functions like the following;

- For dialers that open active connections, runtime_pollOpen will be
  called in between syscall.Bind and syscall.Connect.

- For stream listeners that open passive stream connections,
  runtime_pollOpen will be called just after syscall.Listen.

- For datagram listeners that open datagram connections,
  runtime_pollOpen will be called just after syscall.Bind.

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

Update #5199

R=dvyukov, alex.brainman, minux.ma
CC=golang-dev
https://golang.org/cl/8608044
2013-08-06 23:42:33 +09:00
David du Colombier
33bd9694cd runtime: fix Plan 9 build
The current failures were:

fatal error: runtime: stack split during syscall
goroutine 1 [stack split]:
runtime.findnull(0x105a9080)
        /usr/go/src/pkg/runtime/string.goc:14 fp=0x305aefb8
runtime: unexpected return pc for runtime.errstr called from 0x80
runtime.errstr()
        /usr/go/src/pkg/runtime/sys_plan9_386.s:196 +0x2f fp=0x305aefc8

fatal error: runtime: stack split during syscall
goroutine 2 [stack split]:
runtime.nanotime(0x305bff3c)
        /usr/go/src/pkg/runtime/time_plan9_386.c:9 fp=0x305bff34
notetsleep(0x305bff9c, 0xf8475800, 0xd, 0x0, 0x0, ...)
        /usr/go/src/pkg/runtime/lock_sema.c:195 +0x87 fp=0x305bff48
runtime.notetsleepg(0x305bff9c, 0xf8475800, 0xd)
        /usr/go/src/pkg/runtime/lock_sema.c:266 +0xa4 fp=0x305bff68
runtime.MHeap_Scavenger()
        /usr/go/src/pkg/runtime/mheap.c:463 +0xc2 fp=0x305bffd0
runtime.goexit()
        /usr/go/src/pkg/runtime/proc.c:1332 fp=0x305bffd4
created by runtime.main
        /usr/go/src/pkg/runtime/proc.c:168

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12128043
2013-08-06 07:37:26 -07:00
Brad Fitzpatrick
b2fcdfa5fd net: detect bad F_DUPFD_CLOEXEC on OS X 10.6
On 10.6, OS X's fcntl returns EBADF instead of EINVAL.

R=golang-dev, iant, dave
CC=golang-dev
https://golang.org/cl/12493043
2013-08-06 07:18:06 -07:00
Rob Pike
82f5ca1ef0 runtime: change int32 to intgo in findnull and findnullw
Update #6046.
This CL just does findnull and findnullw. There are other functions
to fix but doing them a few at a time will help isolate any (unlikely)
breakages these changes bring up in architectures I can't test
myself.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12520043
2013-08-06 21:49:03 +10:00
Dmitriy Vyukov
429a67e300 net: fix intentional build breakage introduced in 12413043
R=alex.brainman
CC=golang-dev
https://golang.org/cl/12502044
2013-08-06 14:43:36 +04:00
Dmitriy Vyukov
04b1cfa946 net: reduce number of memory allocations during IO operations
Embed all data necessary for read/write operations directly into netFD.

benchmark                    old ns/op    new ns/op    delta
BenchmarkTCP4Persistent          27669        23341  -15.64%
BenchmarkTCP4Persistent-2        18173        12558  -30.90%
BenchmarkTCP4Persistent-4        10390         7319  -29.56%

This change will intentionally break all builders to see
how many allocations they do per read/write.
This will be fixed soon afterwards.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/12413043
2013-08-06 14:40:10 +04:00
Dmitriy Vyukov
9c0500b466 runtime: use gcpc/gcsp during traceback of goroutines in syscalls
gcpc/gcsp are used by GC in similar situation.
gcpc/gcsp are also more stable than gp->sched,
because gp->sched is mutated by entersyscall/exitsyscall
in morestack and mcall. So it has higher chances of being inconsistent.
Also, rename gcpc/gcsp to syscallpc/syscallsp.

This is the same as reverted change 12250043
with save marked as textflag 7.
The problem was that if save calls morestack,
then subsequent lessstack spoils g->sched.pc/sp.
And that bad values were remembered in g->syscallpc/sp.
Entersyscallblock had the same problem,
but it was never triggered to date.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12478043
2013-08-06 13:38:44 +04:00
Kyle Lemons
321ede78e3 flag: document the zero value of FlagSet
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12403043
2013-08-06 16:48:19 +10:00
Keith Randall
034d5fcc30 runtime: Use old reflect.call implementation from cgo.
Basically a partial rollback of 12053043 until I can
figure out what is really going on.
Fixes bug 6051.

R=golang-dev
CC=golang-dev
https://golang.org/cl/12496043
2013-08-05 17:53:08 -07:00
Russ Cox
d3066e47b1 runtime/pprof: test multithreaded profile, remove OS X workarounds
This means that pprof will no longer report profiles on OS X.
That's unfortunate, but the profiles were often wrong and, worse,
it was difficult to tell whether the profile was wrong or not.

The workarounds were making the scheduler more complex,
possibly caused a deadlock (see issue 5519), and did not actually
deliver reliable results.

It may be possible for adventurous users to apply a patch to
their kernels to get working results, or perhaps having no results
will encourage someone to do the work of creating a profiling
thread like on Windows. Issue 6047 has details.

Fixes #5519.
Fixes #6047.

R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/12429045
2013-08-05 19:49:02 -04:00
Brad Fitzpatrick
d8e27db395 undo CL 12486043 / ab644299d124
Uglier.

««« original CL description
all: use strings.IndexByte instead of Index where possible

R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/12486043
»»»

R=golang-dev
CC=golang-dev
https://golang.org/cl/12485044
2013-08-05 16:27:24 -07:00
Brad Fitzpatrick
4c772cda54 all: use strings.IndexByte instead of Index where possible
R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/12486043
2013-08-05 15:46:06 -07:00
Pieter Droogendijk
dd6f49ddca container/heap: add Fix and document the min is element 0.
Fixes #5372.
Fixes #5577.

R=gri, rsc, bradfitz, r
CC=golang-dev
https://golang.org/cl/12265043
2013-08-05 15:45:39 -07:00
Brad Fitzpatrick
37feacf623 net: use F_DUPFD_CLOEXEC when duping fds
This means that in the common case (modern kernel), we only
make 1 system call to dup instead of two, and we also avoid
grabbing the syscall.ForkLock.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/12476043
2013-08-05 15:43:45 -07:00
Keith Randall
f7910128e7 reflect: Get rid of the test for the error message when
you do reflect.call with too big an argument list.
Not worth the hassle.

Fixes #6023
Fixes #6033

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/12485043
2013-08-05 15:08:37 -07:00